﻿namespace = harem_politics

#################
##Begging event##
#################

scripted_trigger harem_politics_demoted_consort_trigger = {
	is_physically_able_ai_adult = yes
	is_demoted_consort_trigger = yes
	trigger_if = {
		limit = {
			OR = {
				has_opinion_modifier = {
					target = root
					modifier = divorced_me_as_gc
				}

				has_opinion_modifier = {
					target = root
					modifier = demoted_me_as_gc
				}

				has_opinion_modifier = {
					modifier = dismissed_me_as_gc
					target = root
				}
			}
		}
		root = {
			highest_held_title_tier >= tier_kingdom
			NOT = {
				government_has_flag = government_is_tribal
			}
		}
	}
	NOR = {
		has_character_flag = flag_pleaded_for
		AND = {
			exists = root.primary_spouse 
			this = root.primary_spouse 
		}
		AND = { 
			has_court_position = grand_consort_court_position
			OR = {
				has_opinion_modifier = {
					target = root
					modifier = divorced_me_as_gc
				}

				has_opinion_modifier = {
					target = root
					modifier = demoted_me_as_gc
				}

				has_opinion_modifier = {
					modifier = dismissed_me_as_gc
					target = root
				}
			}
		}
		AND = { 
			is_spouse_of = root
			OR = {
				has_opinion_modifier = {
					target = root
					modifier = divorced_me_as_ss
				}

				has_opinion_modifier = {
					target = root
					modifier = demoted_me_as_ss
				}

				has_opinion_modifier = {
					modifier = dismissed_me_as_ss
					target = root
				}
			}
		}
	}
	is_courtier_of = root
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
	OR = {
		has_opinion_modifier = {
			target = root
			modifier = demoted_me_as_ps
		}
		has_opinion_modifier = {
			target = root
			modifier = demoted_me_as_gc
		}
		has_opinion_modifier = {
			target = root
			modifier = demoted_me_as_ss
		}
	}
}

harem_politics.0001 = {
	type = character_event
	title = harem_politics.0001.t
	desc = {
		desc = harem_politics.0001.start.desc
		first_valid = {
			triggered_desc = { #Is parent of root
				trigger = {
					scope:beggar = {
						is_parent_of = root
					}
				}
				desc = harem_politics.0001.child.desc
			}
			triggered_desc = { #Root is their brother
				trigger = {
					scope:beggar = {
						is_sibling_of = root
					}
					is_male = yes
				}
				desc = harem_politics.0001.brother.desc
			}
			triggered_desc = { #Root is their sister
				trigger = {
					scope:beggar = {
						is_sibling_of = root
					}
					is_female = yes
				}
				desc = harem_politics.0001.sister.desc
			}
			triggered_desc = { #Root is their father
				trigger = {
					scope:beggar = {
						is_child_of = root
					}
					is_male = yes
				}
				desc = harem_politics.0001.father.desc
			}
			triggered_desc = { #Root is their mother
				trigger = {
					scope:beggar = {
						is_child_of = root
					}
					is_female = yes
				}
				desc = harem_politics.0001.mother.desc
			}
			triggered_desc = {
				desc = harem_politics.0001.generic_1.desc
			}
		}
		desc = harem_politics.0001.end.desc
	}
	theme = realm
	
	left_portrait = { 	
		character = root
		animation = dismissal
	}
	
	right_portrait = { 	
		character = scope:beggar
		animation = beg
	}
	
	lower_center_portrait = { 	
		character = scope:demoted_consort
	}
	
	trigger = {
		any_consort = {
			harem_politics_demoted_consort_trigger = yes
		}
		OR = {
			any_courtier = {
				is_physically_able_ai = yes
				NOR = {
					has_trait = ill
					has_trait = wounded
					has_character_modifier = recently_tortured
					has_hook = root
					has_strong_hook = root
					has_character_flag = made_a_plea_flag
				}
				age >= 15
				OR = {
					AND = {
						is_travelling = yes
						current_travel_plan = {
							travel_plan_owner = root
						}
					}
					AND = {
						is_travelling = no
						root = {
							is_travelling = no
						}
					}
				}
			}
			any_vassal = {
				OR = {
					AND = {
						is_available_at_peace_ai_adult = yes
						NOR = {
							has_trait = ill
							has_trait = wounded
							has_character_modifier = recently_tortured
							has_hook = root
							has_strong_hook = root
							has_character_flag = made_a_plea_flag
						}
					}
					any_courtier = {
						is_available_at_peace_ai_adult = yes
						NOR = {
							has_trait = ill
							has_trait = wounded
							has_character_modifier = recently_tortured
							has_hook = root
							has_strong_hook = root
							has_character_flag = made_a_plea_flag
						}
					}
				}
			}
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOR = {
			has_character_modifier = mourner_modifier
			# To avoid making things messier
			religion = religion:islam_religion
		}
	}
	
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.3
			any_consort = {
				has_demoted_or_divorced_as_ps_opinion_trigger = {
					TARGET = root
				}
			}
		}
		modifier = {
			add = 0.3
			has_character_flag = recently_set_primary_spouse_flag
		}
	}
	
	immediate = {
		save_scope_as = actor
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				harem_politics_demoted_consort_trigger = yes
			}
			add_to_list = demoted_consorts_list
		}

		random_in_list = {
			list = demoted_consorts_list
			weight = {
				base = 10
				modifier = { #The main spouse is more important
					has_demoted_or_divorced_as_ps_opinion_trigger = {
						TARGET = root
					}
					add = 100
				}
				modifier = { #Noblewomen are more important
					is_lowborn = no
					add = 10
				}
				modifier = { #Relatives of rulers are more important
					any_close_or_extended_family_member = {
						is_landed_or_landless_administrative = yes
					}
					add = 10
				}
				modifier = { #Child of vassals are more important
					any_close_or_extended_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Child of powerful vassals are more important
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
					add = 20
				}
				modifier = { #If they're related to root, it's even better
					any_close_or_extended_family_member = {
						is_close_family_of = root
					}
					add = 20
				}
				modifier = { #If they're related to root, it's even better
					exists = dynasty
					exists = root.dynasty
					dynasty = root.dynasty
					add = 10
				}
				modifier = { #If they're related to root, it's even better
					exists = house
					exists = root.house
					house = root.house
					add = 10
				}
				modifier = { #Having kids make people pity you
					any_child = {
						count >= 1
					}
					add = 5
				}
				modifier = { #Sharing root faith is even better
					faith = root.faith
					add = 15
				}
			}
			save_scope_as = demoted_consort
		}
		scope:demoted_consort = {
			every_close_or_extended_family_member = {
				limit = {
					AND = {	
						is_available_at_peace_ai_adult = yes
						NOR = {
							has_trait = ill
							has_trait = wounded
							has_character_modifier = recently_tortured
							has_hook = root
							has_strong_hook = root
							has_character_flag = made_a_plea_flag
							this = root
							is_courtier_of = root
						}
						any_liege_or_above = {
							this = root
						}
					}
				}
				add_to_list = pleaders_list
			}
			every_relation = {
				type = friend
				limit = {
					AND = {	
						is_available_at_peace_ai_adult = yes
						NOR = {
							has_trait = ill
							has_trait = wounded
							has_character_modifier = recently_tortured
							has_hook = root
							has_strong_hook = root
							has_character_flag = made_a_plea_flag
							this = root
							is_courtier_of = root
						}
						any_liege_or_above = {
							this = root
						}
					}
				}
				add_to_list = pleaders_list
			}
			if = {
				limit = {
					exists = scope:demoted_consort.dynasty
				}
				scope:demoted_consort.dynasty = {
					if = {
						limit = {
							any_dynasty_member = {
								is_available_at_peace_ai_adult = yes
								NOR = {
									has_trait = ill
									has_trait = wounded
									has_character_modifier = recently_tortured
									has_hook = root
									has_strong_hook = root
									has_character_flag = made_a_plea_flag
									this = root
									is_courtier_of = root
								}
								any_liege_or_above = {
									this = root
								}
							}
						}
						every_dynasty_member = {
							limit = {
								AND = {	
									is_available_at_peace_ai_adult = yes
									NOR = {
										has_trait = ill
										has_trait = wounded
										has_character_modifier = recently_tortured
										has_hook = root
										has_strong_hook = root
										has_character_flag = made_a_plea_flag
										this = root
										is_courtier_of = root
									}
									any_liege_or_above = {
										this = root
									}
								}
							}
							add_to_list = pleaders_list
						}
					}
				}
			}
		}
		every_vassal = {
			limit = {
				AND = {	
					is_available_at_peace_ai_adult = yes
					NOR = {
						has_trait = ill
						has_trait = wounded
						has_character_modifier = recently_tortured
						has_hook = root
						has_strong_hook = root
						has_character_flag = made_a_plea_flag
					}
				}
			}
			add_to_list = pleaders_list
		}
		every_courtier = {
			limit = {
				AND = {	
					is_physically_able_ai = yes
					NOR = {
						has_trait = ill
						has_trait = wounded
						has_character_modifier = recently_tortured
						has_hook = root
						has_strong_hook = root
						has_character_flag = made_a_plea_flag
						this = scope:demoted_consort
					}
					age >= 15
					OR = {
						AND = {
							is_travelling = yes
							current_travel_plan = {
								travel_plan_owner = root
							}
						}
						AND = {
							is_travelling = no
							root = {
								is_travelling = no
							}
						}
					}
				}
			}
			add_to_list = pleaders_list
		}

		random_in_list = {
			list = pleaders_list
			limit = {
				NOR = {
					has_hook = root
					has_strong_hook = root
					has_character_flag = made_a_plea_flag
					is_liege_or_above_of = root
				}
			}
			weight = { 
				base = 30
				modifier = { #Relatives are concerned
					is_extended_family_of = scope:demoted_consort
					add = 10
				}
				modifier = { #Close relatives are even more concerned
					is_close_family_of = scope:demoted_consort
					add = 20
				}
				modifier = { #More if they're recipient's parents
					is_parent_of = scope:demoted_consort
					add = 15
				}
				modifier = { #Children listen to their parents
					is_parent_of = root
					is_landed_or_landless_administrative = no
					add = 10
				}
				modifier = { #Dynasty members are concernced
					exists = dynasty
					exists = scope:demoted_consort.dynasty
					dynasty = scope:demoted_consort.dynasty
					add = 10
				}
				modifier = { #House members are concernced
					exists = house
					exists = scope:demoted_consort.house
					house = scope:demoted_consort.house
					add = 20
				}
				modifier = { #Vassals are more concerned
					is_vassal_of = root
					add = 10
				}
				modifier = { #Powerful characters are more concerned
					OR = {
						is_councillor_of = root
						is_powerful_vassal_of = root
					}
					add = 5
				}
				modifier = { #Barons are ignored
					highest_held_title_tier = tier_barony
					add = -30
				}
				modifier = { #Someone with a high opinion is very likely to plea
					add = 20
					opinion = {
						target = scope:demoted_consort
						value >= high_positive_opinion
					}
				}
				modifier = { #Children listen to their parents
					AND = {
						OR = {
							root.faith = { has_doctrine = tenet_ancestor_worship }
							root.culture = { has_cultural_tradition = tradition_mystical_ancestors }
						}
						is_parent_of = root
						is_landed_or_landless_administrative = no
						OR = {
							opinion = {
								target = scope:demoted_consort
								value >= low_positive_opinion
							}
							AND = {
								exists = dynasty
								exists = scope:demoted_consort.dynasty
								dynasty = scope:demoted_consort.dynasty
							}
							any_close_or_extended_family_member = {
								this = scope:demoted_consort
							}
						}
					}
					add = 100
				}
				modifier = { #Zealous characters are more likely if they have virtuous traits
					scope:demoted_consort.num_virtuous_traits > 0
					scope:demoted_consort.num_sinful_traits < 1
					OR = {
						ai_zeal >= high_positive_ai_value
						has_trait = zealous
					}
					add = 15
				}
				modifier = { #The court chaplain might intervine if the recipient doesn't have sinful traits
					is_councillor_of = root
					has_council_position = councillor_court_chaplain
					scope:demoted_consort.num_sinful_traits < 1
					add = 10
				}
				modifier = { #Zealous characters are less likely if they have sinful traits
					scope:demoted_consort.num_sinful_traits >= 1
					OR = {
						ai_zeal >= high_positive_ai_value
						has_trait = zealous
						has_council_position = councillor_court_chaplain
					}
					add = -15
				}
				modifier = { #Same culture is more likely
					culture = root.culture
					add = 5
				}
				modifier = { #Different recipient faith makes them less likely. Although cynicals don't care about this.
					NOR = { 
						faith = scope:demoted_consort.faith
						has_trait = cynical
					}
					add = -15
				}
				modifier = { #More likely if they don't approve of concubinage
					scope:demoted_consort = {
						is_concubine = yes
					}
					NOR = { 
						hp_accepts_concubinage = yes
					}
					add = 10
				}
				modifier = { #House heads are more concerned
					exists = house
					exists = scope:demoted_consort.house
					house = scope:demoted_consort.house
					is_house_head = yes
					add = 10
				}
				modifier = { #Dynasty heads are more concerned
					exists = dynasty
					exists = scope:demoted_consort.dynasty
					dynasty = scope:demoted_consort.dynasty
					is_dynast = yes
					add = 10
				}
				modifier = { #Just characters are more likely to jump if the recipient isn't a criminal.
					AND = {
						has_trait = just
						root = { 
							NOT = { has_imprisonment_reason = scope:demoted_consort }
						}
					}
					add = 10
				}
				modifier = { #Just characters are less likely to jump if the recipient is a criminal.
					AND = {
						has_trait = just
						root = { 
							has_imprisonment_reason = scope:demoted_consort 
						}
					}
					add = -10
				}
				modifier = { #Traits considerations
					OR = {
						has_trait = brave
						has_trait = stubborn
						has_trait = ambitious
					}
					NOR = {
						has_trait = craven
						has_trait = fickle
						has_trait = shy
					}
					add = 10
				}
				modifier = { #Traits considerations
					OR = {
						has_trait = craven
						has_trait = fickle
						has_trait = shy
					}
					NOR = {
						has_trait = brave
						has_trait = stubborn
						has_trait = ambitious
					}
					add = -15
				}
				modifier = { #Evil consorts are not likely to participate
					AND = {
						harem_politics_evil_consort_trigger = yes
						is_consort_of = root
					}
					add = -30
				}
				modifier = { #Children of the marriage are likely to make a plea
					AND = {
						is_child_of = root
						is_child_of = scope:demoted_consort
					}
					add = 20
				}
				modifier = { #Demoted consorts
					is_demoted_consort_trigger = yes
					add = -40
				}
			}
			save_scope_as = beggar
		}
		if = {
			limit = {
				is_married = yes
				allowed_more_spouses = no
			}
			every_spouse = {
				limit = {
					NOR = {
						this = scope:demoted_consort
						has_strong_hook = root
					}
				}
				add_to_list = demoted_recipient_list
			}

			random_in_list = {
				list = demoted_recipient_list
				weight = {
					base = 200
					modifier = { #The Primary Spouse is too important
						this = root.primary_spouse
						add = -75
					}
					modifier = { #The Grand Consort is too important
						is_grand_consort_trigger = yes
						add = -50
					}
					modifier = { #Noblewomen are more important
						is_lowborn = yes
						add = 20
					}
					modifier = { #Relatives of rulers are more important
						any_close_or_extended_family_member = {
							is_landed_or_landless_administrative = yes
						}
						add = -10
					}
					modifier = { #Child of vassals are more important
						any_close_or_extended_family_member = {
							is_vassal_of = root
						}
						add = -10
					}
					modifier = { #Child of powerful vassals are more important
						any_close_or_extended_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
							}
						}
						add = -50
					}
					modifier = {
						any_close_or_extended_family_member = {
							is_close_family_of = root
						}
						add = -20
					}
					modifier = { 
						any_child = {
							count >= 1
						}
						add = -10
					}
					modifier = { 
						any_child = {
							count >= 3
						}
						add = -20
					}
					modifier = { 
						any_child = {
							this = root.player_heir
						}
						add = -50
					}
					modifier = { #Sharing root faith is even better
						faith = root.faith
						add = -20
					}
					modifier = { #Lovers and friends
						OR = {
							has_character_modifier = favored_consort_modifier
							has_relation_best_friend = root
							has_relation_friend = root
							has_relation_lover = root
							has_relation_soulmate = root
						}
						add = -50
					}
					modifier = { #Enemies and unfavored consorts
						OR = {
							has_character_modifier = forgotten_consort_modifier
							has_character_modifier = unfavored_consort_modifier
							has_relation_nemesis = root
							has_relation_rival = root
						}
						add = 50
					}
				}
				save_scope_as = possible_recipient
			}
		}
	}
	
	option = { # Restore their position
		name = harem_politics.0001.a
		if = {
			limit = { #Restore the PS
				scope:demoted_consort = {
					has_demoted_or_divorced_as_ps_opinion_trigger = {
						TARGET = root
					}
				}
			}
			custom_tooltip = harem_politics.0001.a.tt.ps
		}
		else_if = { #Restore the Grand Consort
			limit = {
				scope:demoted_consort = {
					OR = {
						has_opinion_modifier = {
							target = root
							modifier = divorced_me_as_gc
						}
		
						has_opinion_modifier = {
							target = root
							modifier = demoted_me_as_gc
						}
		
						has_opinion_modifier = {
							modifier = dismissed_me_as_gc
							target = root
						}
					}
				}
				highest_held_title_tier >= tier_kingdom
				NOT = {
					government_has_flag = government_is_tribal
				}
			}
			custom_tooltip = harem_politics.0001.a.tt.gc
		}
		else = { #Restore a SS
			custom_tooltip = harem_politics.0001.a.tt.ss
		}
		custom_tooltip = harem_politics.0001.a.tt.demotion
		trigger = {
			scope:demoted_consort = {
				OR = {
					AND = { #Former PS
						has_demoted_or_divorced_as_ps_opinion_trigger = {
							TARGET = root
						}
						OR = {
							is_spouse_of = root
							AND = {
								is_concubine_of = root
								root = {
									allowed_more_spouses = yes
								}
							}
						}
					}
					AND = { #Former GC
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_gc
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_gc
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_gc
								target = root
							}
						}
						root = {
							highest_held_title_tier >= tier_kingdom
							NOT = {
								government_has_flag = government_is_tribal
							}
						}
						OR = {	
							AND = {	
								is_concubine_of = root
								root = {
									OR = {	
										AND = {
											hp_accepts_polygamy = yes
											allowed_more_spouses = yes
										}
										hp_accepts_polygamy = no
									}
								}
							}
							is_spouse_of = root
						}
					}
					AND = { #Former SS
						is_concubine_of = root
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_ss
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_ss
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_ss
								target = root
							}
						}
						root = {
							allowed_more_spouses = yes
						}
					}
				}
				NOT = {
					this = root.primary_spouse
				}
			}
		}
		scope:beggar = {
			add_opinion = {
				target = root
				modifier = plea_heard_opinion
			}
			add_character_flag = {
				flag = made_a_plea_flag
				days = 540
			}
		}
		scope:demoted_consort = {
			add_opinion = {
				target = root
				modifier = reinstated_me_opinion
			}
			add_opinion = {
				target = scope:beggar
				modifier = plead_for_me_opinion
			}
			if = {
				limit = {
					NOR = {
						has_relation_best_friend = scope:beggar
						has_relation_friend = scope:beggar
						has_relation_potential_friend = scope:beggar
					}
				}
				progress_towards_friend_effect = {
					CHARACTER = scope:beggar
					REASON = plead_for_me_reason
					OPINION = 0
				}
			}
			calyver_favor_huge_gain_effect = yes
		}
		hidden_effect = {
			if = { # Former primary spouse is a secondary spouse
				limit = {
					scope:demoted_consort = {
						AND = {
							has_demoted_or_divorced_as_ps_opinion_trigger = {
								TARGET = root
							}
							is_spouse_of = root
							NOT = {
								this = root.primary_spouse
							}
						}
					}
				}
				scope:demoted_consort = {
					save_scope_as = recipient
				}
				set_primary_spouse_effect = yes
			}
			if = { # Former primary spouse is a concubine
				limit = {
					scope:demoted_consort = {
						AND = {
							has_demoted_or_divorced_as_ps_opinion_trigger = {
								TARGET = root
							}
							is_concubine_of = root
						}
					}
				}
				if = { # Root is NOT allowed to have more spouses. A spouse must be demoted
					limit = {
						allowed_more_spouses = no
						exists = scope:possible_recipient
					}
					spouse_demotion_effect = {
						ACTOR = root
						RECIPIENT = scope:possible_recipient
					}
					clear_saved_scope = recipient
				}
				if = {
					limit = {
						is_female = yes
					}
					marry_matrilineal = scope:demoted_consort
				}
				else = {
					marry = scope:demoted_consort
				}
				scope:demoted_consort = {
					save_scope_as = secondary_recipient
				}
				save_scope_as = secondary_actor
				save_scope_as = recipient
				marriage_interaction_on_accept_effect = yes
				clear_saved_scope = recipient
				if = {
					limit = {
						exists = primary_spouse
						primary_spouse = {
							NOT = {
								this = scope:demoted_consort
							}
						}
					}
					scope:demoted_consort = {
						save_scope_as = recipient
					}
					set_primary_spouse_effect = yes
				}
			}
			
			if = { # Former Grand Consort
				limit = {
					scope:demoted_consort = {
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_gc
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_gc
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_gc
								target = root
							}
						}
						root = {
							highest_held_title_tier >= tier_kingdom
							NOT = {
								government_has_flag = government_is_tribal
							}
						}
					}
				}
				if = { #Is a concubine
					limit = {
						scope:demoted_consort = {
							is_concubine_of = root
						}
					}
					if = { # Root accepts polygamy
						limit = {
							hp_accepts_polygamy = yes
						}
						if = { # Root is NOT allowed to have more spouses. A spouse must be demoted
							limit = {
								allowed_more_spouses = no
								exists = scope:possible_recipient
							}
							spouse_demotion_effect = {
								ACTOR = root
								RECIPIENT = scope:possible_recipient
							}
							clear_saved_scope = recipient
						}
						if = {
							limit = {
								is_female = yes
							}
							marry_matrilineal = scope:demoted_consort
						}
						else = {
							marry = scope:demoted_consort
						}
						scope:demoted_consort = {
							save_scope_as = secondary_recipient
						}
						save_scope_as = secondary_actor
						save_scope_as = recipient
						marriage_interaction_on_accept_effect = yes
					}
				}
				if = { #If there is a Grand Consort, they are demoted too
					limit = {
						any_consort = {
							has_court_position = grand_consort_court_position
							is_courtier_of = root
						}
					}
					random_consort = {
						limit = {
							has_court_position = grand_consort_court_position
							is_courtier_of = root
						}
						save_scope_as = current_grand_consort
					}
					revoke_court_position = {
						recipient = scope:current_grand_consort
						court_position = grand_consort_court_position
					}
				}
				appoint_court_position = {
					recipient = scope:demoted_consort
					court_position = grand_consort_court_position
				}
			}
			if = { # Former SS is a concubine
				limit = {
					scope:demoted_consort = {
						is_concubine_of = root
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_ss
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_ss
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_ss
								target = root
							}
						}
					}
				}
				save_scope_as = secondary_actor
				if = { # Root is NOT allowed to have more spouses. A spouse must be demoted
					limit = {
						allowed_more_spouses = no
						exists = scope:possible_recipient
					}
					spouse_demotion_effect = {
						ACTOR = root
						RECIPIENT = scope:possible_recipient
					}
					clear_saved_scope = recipient
				}
				if = {
					limit = {
						is_female = yes
					}
					marry_matrilineal = scope:demoted_consort
				}
				else = {
					marry = scope:demoted_consort
				}
				scope:demoted_consort = {
					save_scope_as = secondary_recipient
				}
				save_scope_as = recipient
				marriage_interaction_on_accept_effect = yes
			}
		}
		
		if = { #If you are just, you won't forgive a criminal
			limit = {
				has_imprisonment_reason = scope:demoted_consort
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		if = { #If you are zealous, you won't forgive a sinner
			limit = {
				scope:demoted_consort.num_virtuous_traits = 0
				scope:demoted_consort.num_sinful_traits >= 1
			}
			stress_impact = {
				zealous = minor_stress_impact_gain
			}
		}
		stress_impact = {
			stubborn = minor_stress_impact_gain
			fickle = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = { #Stress management
				add = -30
				OR = {
					AND = {
						has_imprisonment_reason = scope:demoted_consort
						has_trait = just
					}
					AND = {
						scope:demoted_consort.num_virtuous_traits = 0
						scope:demoted_consort.num_sinful_traits >= 1
						has_trait = zealous
					}
				}
			}
			modifier = { #Less likely if stubborn
				add = -30
				has_trait = stubborn
			}
			modifier = { #More likely if fickle
				add = 35
				OR = {
					has_trait = fickle
					has_trait = compassionate
					has_trait = forgiving
				}
			}
			modifier = { #More likely if spouse comes from a prominent family
				add = 20
				scope:demoted_consort = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
				}
			}
			modifier = { #More likely if primary spouse does not come from a prominent family
				add = 10
				exists = primary_spouse
				primary_spouse = {
					OR = {
						any_close_family_member = {
							NOR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
							}
						}
						is_lowborn = yes
					}
				}
				scope:demoted_consort = {
					has_demoted_or_divorced_as_ps_opinion_trigger = {
						TARGET = root
					}
				}
			}
			modifier = { #More likely if beggar comes from a prominent family
				add = 10
				scope:beggar = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_close_family_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = { #More likely if zealous
				add = 10
				AND = {
					scope:demoted_consort.num_virtuous_traits >= 1
					scope:demoted_consort.num_sinful_traits = 0
					has_trait = zealous
				}
			}
			modifier = { #More likely if just
				add = 20
				AND = {
					has_trait = just
					NOT = { has_imprisonment_reason = scope:demoted_consort }
				}
			}
			modifier = { #More likely if high opinion of recipient
				add = 10
				opinion = {
					target = scope:demoted_consort
					value >= medium_positive_opinion
				}
			}
			modifier = { #More likely if high opinion of recipient
				add = 15
				opinion = {
					target = scope:demoted_consort
					value >= high_positive_opinion
				}
			}
			modifier = { #More likely if soulmate
				add = 30
				has_relation_soulmate = scope:demoted_consort
			}
			modifier = { #More likely if BFF
				add = 20
				OR = {
					has_relation_best_friend = scope:demoted_consort
					has_relation_lover = scope:demoted_consort
				}
			}
			modifier = { #More likely if friends
				add = 15
				has_relation_friend = scope:demoted_consort
			}
			modifier = { #More likely if high opinion of beggar
				add = 10
				opinion = {
					target = scope:beggar
					value >= medium_positive_opinion
				}
			}
			modifier = { #More likely if low opinion of primary spouse
				add = 15
				scope:demoted_consort = {
					has_demoted_or_divorced_as_ps_opinion_trigger = {
						TARGET = root
					}
				}
				exists = primary_spouse
				opinion = {
					target = root.primary_spouse
					value <= low_negative_opinion
				}
			}
			modifier = { #More likely if they have many children
				add = 15
				scope:demoted_consort = {
					any_child = {
						even_if_dead = yes
						count >= 4
					}
				}
			}
			modifier = { #More likely if they have many children
				add = 5
				scope:demoted_consort = {
					any_child = {
						even_if_dead = yes
						count >= 5
					}
				}
			}
			modifier = { #More likely if the player heir is their child
				add = 30
				scope:demoted_consort = {
					any_child = {
						this = root.player_heir
					}
				}
			}
			modifier = { #Favored consorts
				add = 10
				scope:demoted_consort = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Favored consorts
				add = 20
				scope:demoted_consort = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = { #Favored consorts
				add = 15
				scope:demoted_consort = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
	}
	
	option = { # Compromise - don't reinstate. The consort gets a better position
		name = harem_politics.0001.b
		if = {
			limit = { #PS
				scope:demoted_consort = {
					has_demoted_or_divorced_as_ps_opinion_trigger = {
						TARGET = root
					}
				}
			}
			if = {
				limit = { #Can be a GC
					highest_held_title_tier >= tier_kingdom
					NOT = {
						government_has_flag = government_is_tribal
					}
				}
				custom_tooltip = harem_politics.0001.b.tt.ps_gc
			}
			else_if = {
				limit = { #Can remarry
					root.highest_held_title_tier < tier_kingdom
				}
				custom_tooltip = harem_politics.0001.b.tt.ps_ss
			}
		}
		else_if = { #Restore the Grand Consort
			limit = {
				scope:demoted_consort = {
					OR = {
						has_opinion_modifier = {
							target = root
							modifier = divorced_me_as_gc
						}
		
						has_opinion_modifier = {
							target = root
							modifier = demoted_me_as_gc
						}
		
						has_opinion_modifier = {
							modifier = dismissed_me_as_gc
							target = root
						}
					}
				}
			}
			custom_tooltip = harem_politics.0001.b.tt.ps_ss
		}
		custom_tooltip = harem_politics.0001.a.tt.demotion
		trigger = {
			scope:demoted_consort = {
				OR = {
					AND = { #Former PS
						has_demoted_or_divorced_as_ps_opinion_trigger = {
							TARGET = root
						}
						NOT = {
							is_grand_consort_trigger = yes
						}
						OR = {	
							AND = {	
								is_concubine_of = root
								root = {
									OR = {	
										AND = {
											hp_accepts_polygamy = yes
											any_spouse = {	
												count > 0
											}
											OR = {
												allowed_more_spouses = yes
												AND = {
													allowed_more_spouses = no
													faith = {
														# We are not required to seek approval of a spiritual HoF
														NAND = {
															has_doctrine = doctrine_divorce_approval
															has_doctrine = doctrine_spiritual_head
															exists = religious_head
														}
														# We are not required to seek approval of a house head
														NAND = {
															has_doctrine = doctrine_divorce_approval
															exists = scope:actor.house
															exists = scope:actor.house.house_head
															scope:actor = { is_house_head = no }
														}
														NOT = { 
															has_doctrine = doctrine_divorce_disallowed
														}
													}
													culture = {
														NOT = {
															has_cultural_parameter = cannot_divorce
														}
													}
												}
											}
										}
										hp_accepts_polygamy = no
									}
									highest_held_title_tier >= tier_kingdom
									NOT = {
										government_has_flag = government_is_tribal
									}
								}
							}
							AND = {
								is_spouse_of = root
								root = {
									highest_held_title_tier >= tier_kingdom
									NOT = {
										government_has_flag = government_is_tribal
									}
								}
							}
						}
					}
					AND = { #Former GC
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_gc
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_gc
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_gc
								target = root
							}
						}
						is_concubine_of = root
						root = {
							AND = {
								hp_accepts_polygamy = yes
								any_spouse = {	
									count > 0
								}
								OR = {	
									allowed_more_spouses = yes
									AND = {
										allowed_more_spouses = no
										faith = {
											# We are not required to seek approval of a spiritual HoF
											NAND = {
												has_doctrine = doctrine_divorce_approval
												has_doctrine = doctrine_spiritual_head
												exists = religious_head
											}
											# We are not required to seek approval of a house head
											NAND = {
												has_doctrine = doctrine_divorce_approval
												exists = scope:actor.house
												exists = scope:actor.house.house_head
												scope:actor = { is_house_head = no }
											}
											NOT = { 
												has_doctrine = doctrine_divorce_disallowed
											}
										}
										culture = {
											NOT = {
												has_cultural_parameter = cannot_divorce
											}
										}
									}
								}
							}
						}
					}
				}
				NOT = {
					this = root.primary_spouse
				}
			}
		}
		scope:beggar = {
			add_opinion = {
				target = root
				modifier = reached_compromise_opinion
			}
			add_character_flag = {
				flag = made_a_plea_flag
				days = 540
			}
		}
		scope:demoted_consort = {
			add_opinion = {
				target = scope:beggar
				modifier = plead_for_me_opinion
			}
			if = {
				limit = {
					NOR = {
						has_relation_best_friend = scope:beggar
						has_relation_friend = scope:beggar
						has_relation_potential_friend = scope:beggar
					}
				}
				progress_towards_friend_effect = {
					CHARACTER = scope:beggar
					REASON = plead_for_me_reason
					OPINION = 0
				}
			}
			add_character_flag = {
				flag = flag_pleaded_for
			}
			calyver_favor_minor_gain_effect = yes
		}
		hidden_effect = {
			#A compromise for a former PS is to remarry them
			if = {
				limit = {
					scope:demoted_consort = {
						AND = {
							has_demoted_or_divorced_as_ps_opinion_trigger = {
								TARGET = root
							}
							NOR = { 
								this = root.primary_spouse 
								is_grand_consort_trigger = yes
							}
						}
					}
				}
				if = { #Is a concubine
					limit = {
						scope:demoted_consort = {
							is_concubine_of = root
						}
					}
					if = { # Root accepts polygamy
						limit = {
							hp_accepts_polygamy = yes
						}
						if = { # Root is NOT allowed to have more spouses. A spouse must be demoted
							limit = {
								allowed_more_spouses = no
								exists = scope:possible_recipient
							}
							spouse_demotion_effect = {
								ACTOR = root
								RECIPIENT = scope:possible_recipient
							}
							clear_saved_scope = recipient
						}
						if = {
							limit = {
								is_female = yes
							}
							marry_matrilineal = scope:demoted_consort
						}
						else = {
							marry = scope:demoted_consort
						}
						scope:demoted_consort = {
							save_scope_as = secondary_recipient
						}
						save_scope_as = secondary_actor
						save_scope_as = recipient
						marriage_interaction_on_accept_effect = yes
					}
				}
				if = { #If root can have a GC, the only compromise is to make former PS a GC
					limit = {
						root.highest_held_title_tier >= tier_kingdom
					}
					if = { #If there is a Grand Consort, they are demoted too
						limit = {
							any_consort = {
								has_court_position = grand_consort_court_position
								is_courtier_of = root
							}
						}
						random_consort = {
							limit = {
								has_court_position = grand_consort_court_position
								is_courtier_of = root
							}
							save_scope_as = current_grand_consort
						}
						revoke_court_position = {
							recipient = scope:current_grand_consort
							court_position = grand_consort_court_position
						}
					}
					appoint_court_position = {
						recipient = scope:demoted_consort
						court_position = grand_consort_court_position
					}
				}
			}
			#The compromise for a former GC is to marry them if faith accepts polygamy
			if = { # Former SS is a concubine
				limit = {
					scope:demoted_consort = {
						OR = {
							has_opinion_modifier = {
								target = root
								modifier = divorced_me_as_gc
							}
			
							has_opinion_modifier = {
								target = root
								modifier = demoted_me_as_gc
							}
			
							has_opinion_modifier = {
								modifier = dismissed_me_as_gc
								target = root
							}
						}
						is_concubine_of = root
						root = {
							AND = {
								hp_accepts_polygamy = yes
								any_spouse = {	
									count > 0
								}
							}
						}
					}
				}
				if = { # Root is NOT allowed to have more spouses. A spouse must be demoted
					limit = {
						allowed_more_spouses = no
						exists = scope:possible_recipient
					}
					spouse_demotion_effect = {
						ACTOR = root
						RECIPIENT = scope:possible_recipient
					}
					clear_saved_scope = recipient
				}
				if = {
					limit = {
						is_female = yes
					}
					marry_matrilineal = scope:demoted_consort
				}
				else = {
					marry = scope:demoted_consort
				}
				scope:demoted_consort = {
					save_scope_as = secondary_recipient
				}
				save_scope_as = secondary_actor
				save_scope_as = recipient
				marriage_interaction_on_accept_effect = yes
			}
		}
		
		stress_impact = {
			stubborn = minor_stress_impact_gain
			fickle = minor_stress_impact_loss
		}
		ai_chance = {
			base = 0
			modifier = { #Stress management
				add = -30
				OR = {
					AND = {
						has_imprisonment_reason = scope:demoted_consort
						has_trait = just
					}
					AND = {
						scope:demoted_consort.num_virtuous_traits = 0
						scope:demoted_consort.num_sinful_traits >= 1
						has_trait = zealous
					}
				}
			}
			modifier = { #More likely if fickle
				add = 30
				OR = {
					has_trait = fickle
					has_trait = compassionate
					has_trait = forgiving
				}
			}
			modifier = { #Less likely if stubborn
				add = -30
				has_trait = stubborn
			}
			modifier = { #More likely if spouse comes from a prominent family
				add = 15
				scope:demoted_consort = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
				}
			}
			modifier = { #More likely if beggar comes from a prominent family
				add = 5
				scope:beggar = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_close_family_of = root
						}
					}
				}
			}
			modifier = { #More likely if zealous
				add = 10
				AND = {
					scope:demoted_consort.num_virtuous_traits >= 1
					scope:demoted_consort.num_sinful_traits = 0
					has_trait = zealous
				}
			}
			modifier = { #More likely if just
				add = 10
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:demoted_consort
				}
			}
			modifier = { #More likely if high opinion of recipient
				add = 10
				opinion = {
					target = scope:demoted_consort
					value >= low_positive_opinion
				}
			}
			modifier = { #More likely if BFF
				add = 25
				has_relation_best_friend = scope:demoted_consort
			}
			modifier = { #More likely if friends
				add = 20
				has_relation_friend = scope:demoted_consort
			}
			modifier = { #More likely if high opinion of beggar
				add = 10
				opinion = {
					target = scope:beggar
					value >= medium_positive_opinion
				}
			}
			modifier = { #More likely if they have many children
				add = 15
				scope:demoted_consort = {
					any_child = {
						even_if_dead = yes
						count >= 4
					}
				}
			}
			modifier = { #More likely if they have many children
				add = 5
				scope:demoted_consort = {
					any_child = {
						even_if_dead = yes
						count >= 5
					}
				}
			}
			modifier = { #Favored consorts
				add = 10
				scope:demoted_consort = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Favored consorts
				add = 10
				scope:demoted_consort = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
	}
	
	option = { # I disagree
		name = harem_politics.0001.c
		scope:beggar = {
			add_opinion = {
				target = root
				modifier = rejected_plea_opinion
			}
			add_character_flag = {
				flag = made_a_plea_flag
				days = 540
			}
		}
		scope:demoted_consort = {
			add_character_flag = {
				flag = flag_pleaded_for
			}
			add_opinion = {
				target = scope:beggar
				modifier = plead_for_me_opinion
			}
		}
		if = { #You should forgive non-criminals
			limit = {
				NOT = { has_imprisonment_reason = scope:demoted_consort }
				has_trait = just
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			fickle = minor_stress_impact_gain
		}
		if = {
			limit = {
				AND = {
					scope:beggar = {
						is_parent_of = root
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
			}
			add_character_modifier = {
				modifier = unfilial_opinion_modifier
				years = 3
			}
		}
		ai_chance = {
			base = 10
			modifier = { #Less likely if fickle
				add = -35
				OR = {
					has_trait = fickle
					has_trait = compassionate
					has_trait = forgiving
				}
			}
			modifier = { #More likely if stubborn
				add = 30
				has_trait = stubborn
			}
			modifier = { #Stress management
				add = -30
				NOT = { has_imprisonment_reason = scope:demoted_consort }
				has_trait = just
			}
			modifier = { #More likely if spouse is lowborn
				add = 15
				scope:demoted_consort = {
					is_lowborn = yes
				}
			}
			modifier = { #More likely if beggar is lowborn
				add = 10
				scope:beggar = {
					is_lowborn = yes
				}
			}
			modifier = { #More likely if low opinion of recipient
				add = 10
				opinion = {
					target = scope:demoted_consort
					value <= low_negative_opinion
				}
			}
			modifier = { #More likely if low opinion of recipient
				add = 10
				opinion = {
					target = scope:demoted_consort
					value <= medium_negative_opinion
				}
			}
			modifier = { #More likely if low opinion of beggar
				add = 10
				opinion = {
					target = scope:beggar
					value <= low_negative_opinion
				}
			}
			modifier = { #More likely if low opinion of beggar
				add = 10
				opinion = {
					target = scope:beggar
					value <= medium_negative_opinion
				}
			}
		}
	}
}

################
##Ruyi's event##
################
scripted_trigger harem_politics_hailan_trigger = {
	is_physically_able_ai_adult = yes
	NOT = {
		any_close_or_extended_family_member = {
			OR = {
				AND = {	
					exists = root.primary_spouse
					this = root.primary_spouse
				}
				is_powerful_vassal_of = root
				is_councillor_of = root
				is_parent_of = root
				is_liege_or_above_of = root
			}
		}
	}
	is_grand_consort_trigger = no
	NOR = {	
		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_soulmate = root
		has_relation_lover = root

		has_trait = pregnant
		has_trait = wounded

		has_strong_hook = root
	}
	harem_politics_punished_consort_trigger = no
	harem_politics_favored_consort_trigger = no
	is_demoted_consort_trigger = no
	is_courtier_of = root
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_ruyi_trigger = {
	is_physically_able_ai_adult = yes
	opinion = {
		target = $HAI$
		value > -12
	}
	NOR = {
		this = root.primary_spouse
		this = $HAI$
		
		has_relation_nemesis = $HAI$
		has_relation_rival = $HAI$
		has_relation_potential_rival = $HAI$

		has_relation_nemesis = root
		has_relation_rival = root
		has_relation_potential_rival = root

		has_trait = pregnant
		has_trait = ill
		has_trait = wounded

		has_strong_hook = root
	}
	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no
	is_grand_consort_trigger = no
	is_courtier_of = root
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_hui_trigger = {
	is_physically_able_ai_adult = yes
	NOR = {
		this = root.primary_spouse
		this = $XIAN$
		this = $HAI$
		
		has_relation_best_friend = $HAI$
		has_relation_friend = $HAI$
		has_relation_soulmate = $HAI$
		has_relation_lover = $HAI$
		has_relation_potential_friend = $HAI$
		has_relation_potential_lover = $HAI$

		has_relation_best_friend = $XIAN$
		has_relation_friend = $XIAN$
		has_relation_soulmate = $XIAN$
		has_relation_lover = $XIAN$
		has_relation_potential_friend = $XIAN$
		has_relation_potential_lover = $XIAN$

		has_trait = calm
		has_trait = shy
		has_trait = craven
		has_trait = pregnant
		has_trait = wounded

		has_strong_hook = root
	}
	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	is_demoted_consort_trigger = no
	harem_politics_evil_consort_trigger = yes
	is_courtier_of = root
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_effect close_relations_opinion_effect = {
	# If we're a clan this interaction affects unity
	add_clan_unity_interaction_effect = {
		CHARACTER = $EXECUTIONER$ 
		TARGET = $VICTIM$
		VALUE = medium_unity_loss
		DESC = clan_unity_execute.desc
		REVERSE_NON_HOUSE_TARGET = no
	}
	# Victim's family & spouse hates executioner
	every_close_family_member = {
		limit = { 
			NOR = { 
				this = $EXECUTIONER$ 
				this = root
			} 
		}
		add_to_temporary_list = victim_family_list
	}
	every_spouse = {
		limit = {
			AND = {
				NOR = {
					this = $EXECUTIONER$
					this = root
					is_in_list = victim_family_list
				}
			}
		}
		add_to_temporary_list = victim_family_list
	}
	
	if = {
		limit = {
			any_in_list = {
				list = victim_family_list
				count > 0
			}
		}
		if = {
			limit = {
				$EXECUTIONER$ = {
					has_execute_reason = $VICTIM$
				}
			}
			every_in_list = {
				list = victim_family_list
				custom = all_close_family_and_spouses
				add_opinion = {
					target = $EXECUTIONER$
					modifier = executed_close_family
				}
			}
		}
		else = {
			every_in_list = {
				list = victim_family_list
				custom = all_close_family_and_spouses
				add_opinion = {
					target = $EXECUTIONER$
					modifier = executed_close_family_crime
				}
			}
		}
	}

	# Victim's dynasty hates executioner
	if = {
		limit = {
			exists = dynasty
			OR = {
				AND = {
					exists = $EXECUTIONER$.dynasty
					NOT = { dynasty = $EXECUTIONER$.dynasty }
				}
				NOT = {
					exists = $EXECUTIONER$.dynasty
				}
			}
			NOT = {
				$EXECUTIONER$ = {
					has_execute_reason = $VICTIM$
				}
			}
		}
		dynasty = {
			every_dynasty_member = {
				limit = {
					NOR = {
						this = $VICTIM$
						is_in_list = victim_family_list
					}
					OR = {
						AND = {
							is_spouse_of = $VICTIM$
							opinion = {
								target = $VICTIM$
								value >= 15
							}
						}
						NOT = { is_spouse_of = $VICTIM$ } 
					}
				}
				custom = all_dynasty_members
				add_to_temporary_list = victim_dynasty_list
				add_opinion = {
					target = $EXECUTIONER$
					modifier = executed_dynasty_member
				}
			}
		}
	}
	
	# Victim's friends and lovers
	every_relation = {
		type = friend
		limit = {
			NOR = {
				this = $EXECUTIONER$ 
				this = $VICTIM$
				is_in_list = victim_family_list
				is_in_list = victim_dynasty_list
			}
		}
		add_to_list = victim_close_relations_list
	}
	every_relation = {
		type = lover
		limit = {
			NOR = {
				this = $EXECUTIONER$ 
				this = $VICTIM$
				is_in_list = victim_family_list
				is_in_list = victim_dynasty_list
				is_in_list = victim_close_relations_list
			}
		}
		add_to_list = victim_close_relations_list
	}
	every_relation = {
		type = best_friend
		limit = {
			NOR = {
				this = $EXECUTIONER$ 
				this = $VICTIM$
				is_in_list = victim_family_list
				is_in_list = victim_dynasty_list
				is_in_list = victim_close_relations_list
			}
		}
		add_to_list = victim_close_relations_list
	}
	every_relation = {
		type = soulmate
		limit = {
			NOR = {
				this = $EXECUTIONER$ 
				this = $VICTIM$
				is_in_list = victim_family_list
				is_in_list = victim_dynasty_list
				is_in_list = victim_close_relations_list
			}
		}
		add_to_list = victim_close_relations_list
	}
	if = {
		limit = {
			any_in_list = {
				list = victim_close_relations_list
				always = yes
			}
		}
		every_in_list = {
			list = victim_close_relations_list
			custom = all_friends_and_lovers
			add_opinion = {
				target = $EXECUTIONER$
				modifier = executed_close_relation_opinion
			}
		}
	}
}

harem_politics.0002 = {
	type = character_event
	title = harem_politics.0002.t
	desc = harem_politics.0002.desc
	theme = unfriendly
	override_background = {
		reference = bedchamber
	}
	
	left_portrait = { 	
		character = root
		animation = dismissal
	}
	
	right_portrait = { 	
		character = scope:ruyi
		animation = beg
	}
	trigger = {
		is_married = yes
		OR = {
			AND = {
				hp_accepts_concubinage = yes
				hp_accepts_polygamy = yes
				any_concubine = { #Hailan is a low-ranked consort
					harem_politics_hailan_trigger = yes
					save_temporary_scope_as = hai_changzai
				}
				any_consort = { #Consort Xian is a mid-ranked consort
					harem_politics_ruyi_trigger = { HAI = scope:hai_changzai }
					save_temporary_scope_as = xian_fei
				}
				OR = {
					AND = {
						NOT = { employs_court_position = grand_consort_court_position }
						any_spouse = { #Noble Consort Gao was the second highest consort and evil
							harem_politics_hui_trigger = { HAI = scope:hai_changzai XIAN = scope:xian_fei }
						}
					}
					AND = {
						employs_court_position = grand_consort_court_position
						any_spouse = { #Noble Consort Gao was the second highest consort and evil
							has_court_position = grand_consort_court_position
							harem_politics_hui_trigger = { HAI = scope:hai_changzai XIAN = scope:xian_fei }
						}
					}
				}
			}
			AND = {
				hp_accepts_concubinage = yes
				hp_accepts_polygamy = no
				any_concubine = { #Hailan is a low-ranked consort
					harem_politics_hailan_trigger = yes
					save_temporary_scope_as = hai_changzai
				}
				any_concubine = { #Consort Xian is a mid-ranked consort
					harem_politics_ruyi_trigger = { HAI = scope:hai_changzai }
					save_temporary_scope_as = xian_fei
				}
				employs_court_position = grand_consort_court_position
				any_concubine = { #Noble Consort Gao was the second highest consort and evil
					has_court_position = grand_consort_court_position
					harem_politics_hui_trigger = { HAI = scope:hai_changzai XIAN = scope:xian_fei }
				}
			}
			AND = {
				hp_accepts_concubinage = no
				hp_accepts_polygamy = yes
				any_spouse = { #Hailan is a low-ranked consort
					harem_politics_hailan_trigger = yes
					save_temporary_scope_as = hai_changzai
				}
				any_spouse = { #Consort Xian is a mid-ranked consort
					harem_politics_ruyi_trigger = { HAI = scope:hai_changzai }
					save_temporary_scope_as = xian_fei
				}
				employs_court_position = grand_consort_court_position
				any_spouse = { #Noble Consort Gao was the second highest consort and evil
					has_court_position = grand_consort_court_position
					harem_politics_hui_trigger = { HAI = scope:hai_changzai XIAN = scope:xian_fei }
				}
			}
		}
		any_consort = {
			is_courtier_of = root
			count >= 4
		}
		NOR = { 
			has_character_flag = had_hailan_event_flag 
			has_character_flag = had_hua_gui_fei_event_flag
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	weight_multiplier = {
		base = 1
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.35
		}
	}

	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				is_landed_or_landless_administrative = no
				is_physically_able_ai_adult = yes
				NOT = { 
					AND = {
						exists = root.primary_spouse
						this = root.primary_spouse 
					}
				}
			}
			add_to_list = consorts_list
		}
		#Hailan
		random_in_list = {
			list = consorts_list
			limit = {
				harem_politics_hailan_trigger = yes
				OR = {
					is_concubine = yes
					AND = {
						root = {
							hp_accepts_concubinage = no
						}
						is_married = yes
					}
				}
			}
			weight = {
				base = 1
				modifier = { #Lowly concubines are more likely to attract bullying
					is_lowborn = yes
					add = 20
				}
				modifier = { #Lowly concubines are more likely to attract bullying
					any_close_or_extended_family_member = {
						NOR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
					add = 30
				}
				modifier = { #If she doesn't have kids, even better
					any_child = {
						even_if_dead = yes
						count >= 1
					}
					add = 20
				}
				modifier = { #Craven characters are easier to target
					OR = {
						has_trait = craven
						has_trait = shy
					}
					add = 40
				}
				modifier = { #Weak characters are easier to target
					has_character_modifier = unfavored_consort_modifier
					add = 10
				}
				modifier = { #Weak characters are easier to target
					has_character_modifier = forgotten_consort_modifier
					add = 20
				}
			}
			save_scope_as = hailan
		}
		#Ruyi
		random_in_list = {
			list = consorts_list
			limit = {
				harem_politics_ruyi_trigger = { HAI = scope:hailan }
			}
			weight = {
				base = 1
				modifier = { #Spouses are more likely to intervene
					is_spouse_of = root
					add = 25
				}
				modifier = { #Powerful consorts are more likely to intervene
					is_lowborn = no
					add = 10
				}
				modifier = { #Powerful consorts are more likely to intervene
					any_close_or_extended_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Powerful consorts will take part in harem politics
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = { #If this consorts is just, even better
					has_trait = just
					add = 20
				}
				modifier = { #Evil consorts won't help a helpless concubine
					harem_politics_evil_consort_trigger = no
					add = 20
				}
				modifier = { #Ruyi is Hailan's friend
					opinion = {
						target = scope:hailan
						value >= low_positive_opinion
					}
					add = 40
				}
				modifier = { #Favored consorts are more confident
					has_character_modifier = favored_consort_modifier
					add = 20
				}
				modifier = { #Favored consorts are more confident
					has_character_modifier = beloved_consort_modifier
					add = 30
				}
			}
			save_scope_as = ruyi
		}
		#Hui
		random_in_list = {
			list = consorts_list
			limit = {
				AND = {
					OR = {
						has_court_position = grand_consort_court_position
						AND = {
							NOT = { has_court_position = grand_consort_court_position }
							ROOT = {
								NOT = { employs_court_position = grand_consort_court_position }
								hp_accepts_concubinage = yes
								hp_accepts_polygamy = yes
							}
						}
					}
					OR = {
						AND = {
							ROOT = {
								hp_accepts_polygamy = no
							}
							is_concubine = yes
						}
						AND = {
							ROOT = {
								hp_accepts_polygamy = yes
							}
							is_married = yes
						}
					}
					harem_politics_hui_trigger = { HAI = scope:hailan XIAN = scope:ruyi }	
				}
			}
			weight = {
				base = 50
				modifier = { #Noble Consort Gao is the second highest-ranked consort
					has_court_position = grand_consort_court_position
					add = 100
				}
				modifier = { #Noble Consort Gao is the second highest-ranked consort
					is_married = yes
					add = 100
				}
				modifier = { #Powerful spouses are more likely to cause havok
					is_lowborn = no
					add = 10
				}
				modifier = { #Powerful spouses are more likely to cause havok
					any_close_or_extended_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Powerful spouses are more likely to cause havok
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = { #If this spouse isn't just, even better
					NOT = { has_trait = just }
					add = 30
				}
				modifier = { #If this spouse is arrogant or callous, better
					OR = {
						has_trait = arrogant
						has_trait = callous
						has_trait = sadistic
						has_trait = arbitrary
					}
					add = 30
				}
				modifier = { #Hui isn't shy
					OR = {
						has_trait = shy
						has_trait = humble
						has_trait = trusting
						has_trait = content
					}
					add = -30
				}
				modifier = { #If this spouse is friends with the main spouse
					opinion = {
						target = root.primary_spouse
						value >= low_positive_opinion
					}
					add = 10
				}
				modifier = {
					opinion = {
						target = scope:ruyi
						value <= 10
					}
					add = 10
				}
				modifier = {
					opinion = {
						target = scope:hailan
						value <= 10
					}
					add = 10
				}
				modifier = { #If this spouse doesn't like Ruyi, better
					OR = {
						has_relation_rival = scope:ruyi
						has_relation_nemesis = scope:ruyi
					}
					add = 40
				}
				modifier = { #If this spouse doesn't like Hailan, better
					OR = {
						has_relation_rival = scope:hailan
						has_relation_nemesis = scope:hailan
					}
					add = 40
				}
				modifier = { #Favored consorts are more confident
					has_character_modifier = favored_consort_modifier
					add = 20
				}
				modifier = { #Favored consorts are more confident
					has_character_modifier = beloved_consort_modifier
					add = 30
				}
			}
			save_scope_as = hui
		}
		hidden_effect = {
			scope:hailan = {
				if = {
					limit = {
						NOT = {
							has_trait = ill
						}
					}
					contract_disease_effect = { 
						DISEASE = ill 
						TREATMENT_EVENT = yes 
					} 
				}
			}
			scope:hui = {
				if = {
					limit = {
						NOT = {
							has_trait = ill
						}
					}
					contract_disease_effect = { 
						DISEASE = ill 
						TREATMENT_EVENT = yes 
					} 
				}
			}
			scope:hailan = {
				add_opinion = {
					target = scope:hui
					modifier = cruelty_opinion
					opinion = -30
				}
			}
			scope:ruyi = {
				add_opinion = {
					target = scope:hui
					modifier = cruelty_opinion
					opinion = -20
				}
			}
		}
	}
	
	option = { # I go to see what's happening
		name = harem_politics.0002.a
		custom_tooltip = harem_politics.0002.a.tt
		trigger_event = {
			id = harem_politics.0003
			days = 4
		}
		stress_impact = {
			lazy = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_energy = 0.1
				ai_honor = 0.2
			}
			modifier = {
				add = 30
				OR = {
					has_trait = diligent
					has_trait = just
				}
			}
			modifier = {
				add = -30
				OR = {
					has_trait = lazy
					has_trait = paranoid
					has_trait = craven
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 5
				opinion = {
					target = scope:ruyi
					value >= low_positive_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 10
				opinion = {
					target = scope:ruyi
					value >= medium_positive_opinion
				}
			}
			modifier = { #Ruyi is favored
				add = 10
				scope:ruyi = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Ruyi is favored
				add = 20
				scope:ruyi = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = { #Ruyi is favored
				add = 15
				scope:ruyi = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
	}
	option = { # I stay in bed
		name = harem_politics.0002.b
		stress_impact = {
			lazy = minor_stress_impact_loss
			just = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		scope:ruyi = {
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -30
			}
			if = {
				limit = { 
					NOR = {
						has_relation_rival = scope:hui
						has_relation_nemesis = scope:hui
						has_relation_friend = scope:hui
						has_relation_best_friend = scope:hui
					}
				}
				set_relation_rival = {
					target = scope:hui
					reason = killed_friend_harem_reason
				}
			}
			if = {
				limit = { 
					NOR = {
						has_relation_rival = root
						has_relation_nemesis = root
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
				set_relation_rival = {
					target = root
					reason = killed_friend_harem_reason
				}
			}
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:ruyi
				}
			}
			calyver_favor_moderate_loss_effect = yes
			if = {
				limit = {
					NOR = {
						has_trait = forgiving
						has_trait = vengeful
					}
				}
				random = {
					chance = 10
					modifier = {
						add = 20
						NOR = {
							has_trait = compassionate
							has_trait = temperate
						}
					}
					modifier = {
						add = 40
						opinion = {
							target = scope:hailan
							value >= low_positive_opinion
						}
					}
					modifier = {
						add = 60
						opinion = {
							target = scope:hailan
							value >= medium_positive_opinion
						}
					}
					add_trait = vengeful
				}
			}
		}
		hidden_effect = {
			scope:hailan = {
				save_scope_as = secondary_recipient
				death = {
					death_reason = death_punishment
					killer = scope:hui
				}
				close_relations_opinion_effect = { VICTIM = scope:hailan EXECUTIONER = scope:hui }
			}
			scope:hui = {
				save_scope_as = authority
				hidden_effect = {
					calyver_favor_minor_gain_effect = yes

					add_character_modifier = { 
						modifier = safe_disease_treatment_success_high_modifier 
						days = disease_treatment_short_duration 
					}
				}
			}
		}
		send_interface_toast = {
			type = event_generic_bad
			title = punished_consort_t
			right_icon = scope:secondary_recipient
			left_icon = scope:authority
			custom_tooltip = punished_consort_severe_desc
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_sociability = 1
				ai_energy = -0.1
				ai_honor = -0.2
			}
			modifier = {
				add = 30
				OR = {
					has_trait = lazy
					has_trait = paranoid
					has_trait = craven
				}
			}
			modifier = {
				add = -30
				OR = {
					has_trait = diligent
					has_trait = just
				}
			}
			modifier = { #AI's opinion of Ruyi
				add = 5
				opinion = {
					target = scope:ruyi
					value <= low_negative_opinion
				}
			}
			modifier = { #AI's opinion of Ruyi
				add = 10
				opinion = {
					target = scope:ruyi
					value <= medium_negative_opinion
				}
			}

			modifier = { #Ruyi is unfavored
				add = 10
				scope:ruyi = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = { #Ruyi is unfavored
				add = 20
				scope:ruyi = {
					has_character_modifier = forgotten_consort_modifier
				}
			}
		}
	}
	after = {
		add_character_flag = had_hailan_event_flag
	}
}

harem_politics.0003 = {
	type = character_event
	title = harem_politics.0002.t
	desc = harem_politics.0003.desc
	theme = unfriendly
	override_background = {
		reference = corridor_night
	}
	
	left_portrait = { 	
		character = scope:hui
		animation = beg
	}
	
	right_portrait = { 	
		character = scope:hailan
		animation = fear
	}
	trigger = {
		
	}
	
	immediate = {
		
	}
	
	option = { # Side with Hailan
		name = harem_politics.0003.a
		scope:hailan = {
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			
			calyver_favor_minor_gain_effect = yes
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
		}
		scope:ruyi = {
			calyver_favor_moderate_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					} 
				}
				set_relation_potential_lover = root
			}
		}
		scope:hui = {
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:ruyi }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:ruyi
				}
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:hailan }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:hailan
				}
			}
			
			add_opinion = {
				target = scope:ruyi
				modifier = meddling_consort_opinion
			}
			add_opinion = {
				target = scope:hailan
				modifier = hatred_spouse_opinion
			}
			add_opinion = {
				target = root
				modifier = ignored_consort_opinion
				opinion = -10
			}
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:hui
				}
			}
			calyver_favor_medium_loss_effect = yes
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
		}
		hidden_effect = {
			add_opinion = {
				target = scope:hui
				modifier = cruelty_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.2
			}
			modifier = {
				add = 20
				OR = {
					has_trait = intellect_good
					has_trait = diligent
					has_trait = just
					has_trait = temperate
				}
			}
			modifier = { #AI's opinion on Hui
				add = 5
				opinion = {
					target = scope:hui
					value >= low_positive_opinion
				}
			}
			modifier = { #AI's opinion on Hui
				add = 20
				opinion = {
					target = scope:hui
					value >= medium_positive_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 5
				opinion = {
					target = scope:ruyi
					value >= low_positive_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 15
				opinion = {
					target = scope:ruyi
					value >= medium_positive_opinion
				}
			}
			modifier = { #AI's opinion on Hailan
				add = 5
				opinion = {
					target = scope:hailan
					value >= low_positive_opinion
				}
			}
			modifier = { #AI's opinion on Hailan
				add = 15
				opinion = {
					target = scope:hailan
					value >= medium_positive_opinion
				}
			}
			modifier = { #More likely if Hui is a powerful vassal's relative
				add = 20
				scope:hui = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = { #More likely if Ruyi is a powerful vassal's relative
				add = 20
				scope:ruyi = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}

			modifier = { #Ruyi's favored
				add = 10
				scope:ruyi = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Ruyi's favored
				add = 20
				scope:ruyi = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = { #Ruyi's favored
				add = 15
				scope:ruyi = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
	}
	option = { # Side with Hui
		name = harem_politics.0003.b
		stress_impact = {
			just = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			sadistic = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}
		save_scope_as = authority
		scope:hailan = {
			save_scope_as = secondary_recipient
			death = {
				death_reason = death_punishment
				killer = root
			}
			close_relations_opinion_effect = { VICTIM = scope:hailan EXECUTIONER = root }
		}
		scope:hui = {
			calyver_favor_big_gain_effect = yes
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					} 
				}
				set_relation_potential_lover = root
			}
		}
		scope:ruyi = {
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -30
			}
			add_opinion = {
				target = scope:hui
				modifier = cruelty_opinion
				opinion = -30
			}
			if = {
				limit = { 
					NOR = {
						has_relation_rival = scope:hui
						has_relation_nemesis = scope:hui
					}
				}
				set_relation_rival = {
					target = scope:hui
					reason = killed_friend_harem_reason
				}
			}
			if = {
				limit = { 
					NOR = {
						has_relation_rival = root
						has_relation_nemesis = root
					}
				}
				set_relation_rival = {
					target = root
					reason = killed_friend_harem_reason
				}
			}
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:ruyi
				}
			}
			calyver_favor_big_loss_effect = yes
			if = {
				limit = {
					NOR = {
						has_trait = forgiving 
						has_trait = vengeful 
					}
				}
				random = {
					chance = 10
					modifier = {
						add = 20
						NOR = {
							has_trait = compassionate
							has_trait = temperate
						}
					}
					modifier = {
						add = 40
						opinion = {
							target = scope:hailan
							value >= low_positive_opinion
						}
					}
					modifier = {
						add = 60
						opinion = {
							target = scope:hailan
							value >= medium_positive_opinion
						}
					}
					add_trait = vengeful
				}
			}
		}
		send_interface_toast = {
			type = event_generic_bad
			title = punished_consort_t
			right_icon = scope:secondary_recipient
			left_icon = scope:authority
			custom_tooltip = punished_consort_severe_desc
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.2
			}
			modifier = {
				add = 30
				OR = {
					has_trait = callous
					has_trait = sadistic
					has_trait = arbitrary
				}
			}
			modifier = {
				add = -30
				OR = {
					has_trait = just
					has_trait = forgiving
					has_trait = compassionate
					has_trait = temperate
					has_trait = generous
				}
			}
			modifier = { #AI's opinion on Hui
				add = 15
				opinion = {
					target = scope:hui
					value >= medium_positive_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 5
				opinion = {
					target = scope:ruyi
					value <= low_negative_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 15
				opinion = {
					target = scope:ruyi
					value <= medium_negative_opinion
				}
			}
			modifier = { #AI's opinion on Hailan
				add = 15
				opinion = {
					target = scope:hailan
					value <= medium_negative_opinion
				}
			}
			modifier = { #More likely if Hui is a powerful vassal's relative
				add = 15
				scope:hui = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}

			modifier = { #Hui's favored
				add = 10
				scope:hui = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Hui's favored
				add = 20
				scope:hui = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = { #Hui's favored
				add = 15
				scope:hui = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
	}
	option = { # Arrest Hui
		name = harem_politics.0003.c
		save_scope_as = actor
		scope:hailan = {
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					} 
				}
				set_relation_potential_lover = root
			}
			
			calyver_favor_big_gain_effect = yes
			hidden_effect = {
				
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
		}
		scope:ruyi = {
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			calyver_favor_moderate_gain_effect = yes
		}
		scope:hui = {
			if = { #If they're a GC, demote them
				limit = {
					has_court_position = grand_consort_court_position
				}
				save_scope_as = employee
				root = {
					save_scope_as = liege
				}
				grand_consort_revoked_court_position_effect = yes
			}
			else = {
				calyver_favor_big_loss_effect = yes
			}

			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:hui
				}
			}
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_low_modifier 
					days = disease_treatment_short_duration 
				}
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:ruyi }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:ruyi
				}
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:hailan }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:hailan
				}
			}
			add_opinion = {
				target = scope:ruyi
				modifier = hatred_spouse_opinion
			}
			add_opinion = {
				target = scope:hailan
				modifier = hatred_spouse_opinion
			}
			save_scope_as = recipient
		}
		imprison = {
			target = scope:hui
			type = house_arrest
		}
		hidden_effect = {
			add_opinion = {
				target = scope:hui
				modifier = cruelty_opinion
				opinion = -20
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.2
			}
			modifier = {
				add = 20
				OR = {
					has_trait = just
					has_trait = vengeful
				}
			}
			modifier = {
				add = -20
				OR = {
					has_trait = forgiving
					has_trait = compassionate
				}
			}
			modifier = { #AI's opinion on Hui
				add = 20
				opinion = {
					target = scope:hui
					value <= medium_negative_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 5
				opinion = {
					target = scope:ruyi
					value >= low_positive_opinion
				}
			}
			modifier = { #AI's opinion on Ruyi
				add = 15
				opinion = {
					target = scope:ruyi
					value >= medium_positive_opinion
				}
			}
			modifier = { #AI's opinion on Hailan
				add = 15
				opinion = {
					target = scope:hailan
					value >= medium_positive_opinion
				}
			}

			modifier = { #More likely if Ruyi is a powerful vassal's relative
				add = 15
				scope:ruyi = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}

			modifier = { #Ruyi's favored
				add = 10
				scope:ruyi = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Ruyi's favored
				add = 20
				scope:ruyi = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = { #Ruyi's favored
				add = 15
				scope:ruyi = {
					has_character_modifier = favor_boost_modifier
				}
			}
		}
		trigger_event = harem_politics.1000
	}

	after = {
		if = {
			limit = {
				scope:hailan = {
					is_alive = yes
				}
			}
			scope:hailan = {
				add_opinion = {
					target = scope:ruyi
					modifier = grateful_opinion
					opinion = 20
				}
				if = {
					limit = { 
						NOR = {
							has_relation_friend = scope:ruyi
							has_relation_best_friend = scope:ruyi
						}
					}
					set_relation_friend = { 
						reason = consort_friendship_reason
						target = scope:ruyi 
					}
				}
			}
		}
	}
}

###################################
##Considering promoting a consort##
###################################
scripted_trigger harem_politics_valid_promotion_consort_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_demoted_consort_trigger = no
	harem_politics_forgotten_consort_trigger = no

	OR = {
		AND = {
			is_concubine_of = root
			root = {
				allowed_more_spouses = yes
			}
		}
		root = {
			can_appoint_char_to_court_position = {
				CHAR = prev
				COURT_POS = grand_consort_court_position
			}
		}
	}

	NOR = { 
		has_character_flag = flag_considered_consort
		this = root.primary_spouse
		has_opinion_modifier = {
			target = root
			modifier = forced_me_concubine_marriage_opinion
		}
		has_relation_rival = root
		has_relation_nemesis = root

		has_character_flag = flag_new_consort
	}
	OR = {
		any_child = {
			is_child_of = root
			even_if_dead = yes
			count >= 3
		}
		any_child = {
			AND = {
				this = root.player_heir
				root.player_heir = {
					age > 8
				}
			}
		}
		any_child = {
			even_if_dead = yes
			has_trait = twin
			is_child_of = root
			count >= 1
		}
		AND = {
			root.faith = { has_doctrine = tenet_reincarnation }
			any_child = {
				has_trait = reincarnation
				is_child_of = root
				even_if_dead = yes
				count >= 1
			}
		}
		any_child = {
			any_spouse = {
				OR = {
					is_councillor_of = root
					is_powerful_vassal_of = root
					highest_held_title_tier >= tier_kingdom
					is_liege_or_above_of = root
				}
			}
			is_child_of = root
			count >= 1
		}
		any_close_family_member = {
			is_liege_or_above_of = root
		}
		AND = {
			OR = {
				any_close_family_member = {
					OR = {
						is_powerful_vassal_of = root
						is_councillor_of = root
						highest_held_title_tier >= tier_kingdom
					}
				}
				has_relation_soulmate = root
				has_relation_lover = root
				has_relation_best_friend = root
				has_relation_friend = root
				has_character_modifier = favored_consort_modifier
				has_character_modifier = beloved_consort_modifier
				AND = {
					root.faith = { has_doctrine = tenet_reincarnation }
					has_trait = reincarnation
				}
			}
			any_child = {
				even_if_dead = yes
				is_child_of = root
				count >= 1
			}
		}
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0004 = {
	type = character_event
	title = harem_politics.0004.t
	desc = {
		desc = harem_politics.0004.start.desc
		first_valid = {
			triggered_desc = { #Is soulmate
				trigger = {
					scope:loved_consort = {
						has_relation_soulmate = root
					}
				}
				desc = harem_politics.0004.soulmate.desc
			}
			triggered_desc = { #Is lover
				trigger = {
					scope:loved_consort = {
						has_relation_lover = root
					}
				}
				desc = harem_politics.0004.lover.desc
			}
			triggered_desc = { #Is BFF
				trigger = {
					scope:loved_consort = {
						has_relation_best_friend = root
					}
				}
				desc = harem_politics.0004.bff.desc
			}
			triggered_desc = { #Is friend
				trigger = {
					scope:loved_consort = {
						has_relation_friend = root
					}
				}
				desc = harem_politics.0004.friend.desc
			}
			triggered_desc = {
				desc = harem_politics.0004.generic_1.desc
			}
		}
		#Promotion reasons
		first_valid = {
		
			#Player heir
			triggered_desc = { #Is mother of heir
				trigger = {
					scope:loved_consort = {
						is_female = yes
						any_child = {
							this = root.player_heir
						}
					}
				}
				desc = harem_politics.0004.heirmother.desc
			}
			triggered_desc = { #Is father of heir
				trigger = {
					scope:loved_consort = {
						is_male = yes
						any_child = {
							this = root.player_heir
						}
					}
				}
				desc = harem_politics.0004.heirfather.desc
			}
			
			#Liege's relative
			triggered_desc = { 
				trigger = {
					exists = scope:consort_relative
					scope:consort_relative = {
						is_liege_or_above_of = root
					}
				}
				desc = harem_politics.0004.liegerelative.desc
			}
			
			triggered_desc = { #Reincarnated child
				trigger = {
					scope:loved_consort = {
						is_female = yes
						any_child = {
							even_if_dead = yes
							has_trait = reincarnation
						}
					}
				}
				desc = harem_politics.0004.sacredmother.desc
			}
			triggered_desc = { #Reincarnated child
				trigger = {
					scope:loved_consort = {
						is_female = no
						any_child = {
							even_if_dead = yes
							has_trait = reincarnation
						}
					}
				}
				desc = harem_politics.0004.sacredfather.desc
			}
			
			#Influential child
			triggered_desc = { 
				trigger = {
					scope:loved_consort = {
						AND = {
							is_female = yes
							any_child = {
								OR = {
									is_councillor_of = root
									is_powerful_vassal_of = root
									highest_held_title_tier >= tier_kingdom
									is_liege_or_above_of = root
									any_spouse = {
										OR = {
											is_councillor_of = root
											is_powerful_vassal_of = root
											highest_held_title_tier >= tier_kingdom
											is_liege_or_above_of = root
										}
									}
								}
							}
						}
					}
				}
				desc = harem_politics.0004.motherpowerfulchild.desc
			}
			triggered_desc = { #Is father of an influential child
				trigger = {
					scope:loved_consort = {
						AND = {
							is_male = yes
							any_child = {
								OR = {
									is_councillor_of = root
									is_powerful_vassal_of = root
									highest_held_title_tier >= tier_kingdom
									is_liege_or_above_of = root
									any_spouse = {
										OR = {
											is_councillor_of = root
											is_powerful_vassal_of = root
											highest_held_title_tier >= tier_kingdom
											is_liege_or_above_of = root
										}
									}
								}
							}
						}
					}
				}
				desc = harem_politics.0004.fatherpowerfulchild.desc
			}
			
			#Councillor
			triggered_desc = {
				trigger = {
					exists = scope:consort_relative
					scope:consort_relative = {
						is_councillor_of = root
					}
				}
				desc = harem_politics.0004.councillor.desc
			}
			
			#Powerful vassal
			triggered_desc = {
				trigger = {
					exists = scope:consort_relative
					scope:consort_relative = {
						is_powerful_vassal_of = root
					}
				}
				desc = harem_politics.0004.powerfulrelative.desc
			}
			
			#Reincarnation
			triggered_desc = { #Reincarnated mother
				trigger = {
					scope:loved_consort = {
						is_female = yes
						has_trait = reincarnation
					}
				}
				desc = harem_politics.0004.sacredwife.desc
			}
			triggered_desc = { #Reincarnated father
				trigger = {
					scope:loved_consort = {
						is_female = no
						has_trait = reincarnation
					}
				}
				desc = harem_politics.0004.sacredhusband.desc
			}

			#Lineage
			triggered_desc = { #Relative of a King or Queen
				trigger = {
					exists = scope:consort_relative
					scope:consort_relative = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				desc = harem_politics.0004.kingqueen.desc
			}
			
			#Fertile
			triggered_desc = {
				trigger = {
					scope:loved_consort = {
						is_female = yes
						OR = {
							any_child = {
								is_child_of = root
								count >= 3
							}
							any_child = {
								even_if_dead = yes
								is_child_of = root
								has_trait = twin
							}
						}
					}
				}
				desc = harem_politics.0004.fertilemother.desc
			}
			triggered_desc = {
				trigger = {
					scope:loved_consort = {
						is_female = no
						OR = {
							any_child = {
								is_child_of = root
								count >= 3
							}
							any_child = {
								even_if_dead = yes
								is_child_of = root
								has_trait = twin
							}
						}
					}
				}
				desc = harem_politics.0004.fertilefather.desc
			}
			triggered_desc = {
				desc = harem_politics.0004.generic_2.desc
			}
		}
		#Current position
		first_valid = {
			#Concubine
			triggered_desc = {
				trigger = {
					scope:loved_consort = {
						is_concubine = yes
					}
				}
				desc = harem_politics.0004.conc.desc
			}
			#S. husband
			triggered_desc = {
				trigger = {
					scope:loved_consort = {
						is_spouse_of = root
						is_male = yes
					}
				}
				desc = harem_politics.0004.sh.desc
			}
			#S. wife
			triggered_desc = {
				trigger = {
					scope:loved_consort = {
						is_spouse_of = root
						is_female = yes
					}
				}
				desc = harem_politics.0004.sw.desc
			}
		}
		desc = harem_politics.0004.end.desc
	}
	theme = family
	
	lower_center_portrait = { 	
		character = scope:loved_consort
	}
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	trigger = {
		OR = {		
			AND = { #Promote a consort to Grand Consort
				gold > 0
				can_employ_court_position_type = grand_consort_court_position
				NOT = { employs_court_position = grand_consort_court_position }
				any_consort = {
					harem_politics_valid_promotion_consort_trigger = yes
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
			}
			AND = { #Promote a concubine to spouse
				allowed_more_spouses = yes
				any_concubine = {
					harem_politics_valid_promotion_consort_trigger = yes
				}
			}
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOR = { 
			has_character_flag = flag_had_promote_consort_event 
			has_character_modifier = mourner_modifier
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		if = {
			limit = {
				gold > 0
				can_employ_court_position_type = grand_consort_court_position
				NOT = { employs_court_position = grand_consort_court_position }
				any_consort = {
					harem_politics_valid_promotion_consort_trigger = yes
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
			}
			every_consort = {
				limit = {
					harem_politics_valid_promotion_consort_trigger = yes
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
				add_to_list = potential_consorts_list
			}
		}
		
		if = {
			limit = {
				allowed_more_spouses = yes
				any_concubine = {
					harem_politics_valid_promotion_consort_trigger = yes
					NOT = {
						is_in_list = potential_consorts_list
					}
				}
			}
			every_concubine = {
				limit = {
					harem_politics_valid_promotion_consort_trigger = yes
					NOT = {
						is_in_list = potential_consorts_list
					}
				}
				add_to_list = potential_consorts_list
			}
		}
		
		random_in_list = {
			list = potential_consorts_list
			limit = {
				is_consort_of = root
			}
			weight = {
				base = 10
				modifier = { #Lowborn
					is_lowborn = no
					add = 15
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 60
				}
				modifier = { #Lover or friend
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
					add = 15
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Valuable heir
					OR = {
						AND = {
							root = {
								OR = {
									has_realm_law = female_only_law
									has_realm_law = female_preference_law
								}
							}
							any_child = {
								is_male = no
							}
						}
						AND = {
							root = {
								OR = {
									has_realm_law = male_only_law
									has_realm_law = male_preference_law
								}
							}
							any_child = {
								is_male = yes
							}
						}
					}
					add = 20
				}
				modifier = { #Many kids!
					any_child = {
						is_child_of = root
						count >= 3
					}
					add = 50
				}
				modifier = { #Special kids
					any_child = {
						even_if_dead = yes
						is_child_of = root
						OR = {
							has_trait = twin
							has_trait = reincarnation
						}
					}
					add = 50
				}
				modifier = { #Player heir's parent
					any_child = {
						AND = {
							this = root.player_heir
							root.player_heir = {
								age > 8
							}
						}
					}
					add = 50
				}
				modifier = { #Rencarnation
					has_trait = reincarnation
					add = 50
				}
				modifier = { #Powerful children
					any_child = {
						any_spouse = {
							OR = {
								is_councillor_of = root
								is_powerful_vassal_of = root
								highest_held_title_tier >= tier_kingdom
								is_liege_or_above_of = root
							}
						}
					}
					add = 30
				}
				modifier = { #Powerful relatives with at least one child
					AND = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								highest_held_title_tier >= tier_kingdom
								is_liege_or_above_of = root
							}
						}
						any_child = {
							even_if_dead = yes
							count >= 1
						}
					}
					add = 30
				}
				modifier = { #Favored consorts
					has_character_modifier = favored_consort_modifier
					add = 20
				}
				modifier = { #Favored consorts
					has_character_modifier = beloved_consort_modifier
					add = 30
				}
			}
			save_scope_as = loved_consort
		}
		scope:loved_consort = {
			if = {
				limit = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							this = root.player_heir
							is_child_of = root
							is_liege_or_above_of = root
						}
					}
				}
				every_close_family_member = {
					limit = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							this = root.player_heir
							is_child_of = root
							is_liege_or_above_of = root
						}
					}
					add_to_list = consort_relatives_list
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = consort_relatives_list
					count >= 1
				}
			}
			random_in_list = {
				list = consort_relatives_list
				weight = {
					base = 1
					modifier = { #Player heir
						OR = {
							this = root.player_heir
							is_liege_or_above_of = root
						}
						add = 150
					}
					modifier = {
						any_spouse = {
							OR = {
								is_councillor_of = root
								is_powerful_vassal_of = root
								highest_held_title_tier >= tier_kingdom
								is_liege_or_above_of = root
							}
						}
						add = 120
					}
					modifier = { #Powerful vassals
						is_powerful_vassal_of = root
						add = 100
					}
					modifier = { #Councillors
						is_councillor_of = root
						add = 50
					}
					modifier = { #Kings and Queens
						highest_held_title_tier >= tier_kingdom
						add = 25
					}
					modifier = { #Kids
						is_child_of = root
						add = 5
					}
				}
				save_scope_as = consort_relative
			}
		}
	}
	
	option = { # Promote them to spouse
		name = harem_politics.0004.a
		trigger = {
			allowed_more_spouses = yes
			scope:loved_consort = {
				is_concubine = yes
			}
		}
		if = {
			limit = {
				has_trait = just
				OR = {
					has_imprisonment_reason = scope:loved_consort
					scope:loved_consort = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		if = {
			limit = {
				is_female = yes
			}
			marry_matrilineal = scope:loved_consort
		}
		else = {
			marry = scope:loved_consort
		}
		scope:loved_consort = {
			save_scope_as = secondary_recipient
		}
		save_scope_as = actor
		save_scope_as = secondary_actor
		save_scope_as = recipient
		marriage_interaction_on_accept_effect = yes
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.1
			}
			modifier = { #More likely if zealous
				add = 15
				AND = {
					scope:loved_consort = {
						num_virtuous_traits >= 1
						num_sinful_traits = 0
					}
					has_trait = zealous
				}
			}
			modifier = { #More likely if just
				add = 15
				AND = {
					has_trait = just
					NOT = { has_imprisonment_reason = scope:loved_consort }
				}
			}
			modifier = { #More likely if high opinion of the concubine
				add = 10
				opinion = {
					target = scope:loved_consort
					value >= high_positive_opinion
				}
			}
			modifier = { #More likely if the concubine is the player heir's parent
				add = 30
				scope:loved_consort = {
					OR = {
						any_child = {
							OR = {
								this = root.player_heir
								any_spouse = {
									OR = {
										is_powerful_vassal_of = root
										is_councillor_of = root
										highest_held_title_tier >= tier_kingdom
										is_liege_or_above_of = root
									}
								}
							}
						}
						any_close_family_member = {
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = { #Soulmate
				has_relation_soulmate = scope:loved_consort
				add = 20
			}
			modifier = { #Lover
				has_relation_lover = scope:loved_consort
				add = 10
			}
			modifier = { #BFF
				has_relation_best_friend = scope:loved_consort
				add = 15
			}
			modifier = { #Friend
				has_relation_friend = scope:loved_consort
				add = 10
			}
			modifier = { #Many kids!
				scope:loved_consort = {
					any_child = {
						even_if_dead = yes
						count >= 3
					}
				}
				add = 20
			}
			modifier = { #Special kids!
				scope:loved_consort = {
					any_child = {
						OR = {
							has_trait = twin
							has_trait = reincarnation
						}
					}
				}
				add = 20
			}
			modifier = { #Reincarnation
				scope:loved_consort = {
					has_trait = reincarnation
				}
				add = 20
			}
			modifier = { #Powerful relatives with at least one child
				scope:loved_consort = {
					AND = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								highest_held_title_tier >= tier_kingdom
							}
						}
						any_child = {
							even_if_dead = yes
							count >= 1
						}
					}
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Lowborns
				scope:loved_consort = {
					is_lowborn = no
				}
				add = 10
			}
			modifier = { #Less likely if the candidate is lowborn and low legitimacy
				add = -35
				is_valid_for_legitimacy_change = yes
				trigger_if = {
					limit = {
						highest_held_title_tier = tier_empire
					}
					legitimacy_level <= 3
				}
				trigger_else_if = {
					limit = {
						highest_held_title_tier = tier_kingdom
					}
					legitimacy_level <= 2
				}
				trigger_else = {
					highest_held_title_tier = tier_duchy
					legitimacy_level <= 1
				}
				scope:loved_consort = {
					is_lowborn = yes
				}
				# Marrying a lowborn SS will reduce legitimacy of feudal rulers
				trigger_if = {
					limit = {
						is_married = yes
					}
					can_have_settled_harem_trigger = yes
				}
				# Marrying a lowborn PS will always reduce legitimacy
				trigger_else = {
					is_married = no
				}
			}
			modifier = { #Culture
				culture = scope:loved_consort.culture
				add = 10
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:loved_consort = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:loved_consort = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = 20
			}
			# Number of spouses
			modifier = {
				trigger_if = {
					limit = {
						primary_title.tier >= 5
					}
					any_spouse = {
						count < 4
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 4
					}
					any_spouse = {
						count < 3
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 3
					}
					any_spouse = {
						count < 2
					}
				}
				trigger_else = {
					any_spouse = {
						count < 1
					}
				}
				NOT = {
					has_government = landless_adventurer_government
				}
				add = 15
			}
		}
	}
	
	option = { # Promote them to Grand Consort
		name = harem_politics.0004.b
		trigger = {
			gold > 0
			can_appoint_char_to_court_position = {
				CHAR = scope:loved_consort
				COURT_POS = grand_consort_court_position
			}
			NOT = { employs_court_position = grand_consort_court_position }
		}
		appoint_court_position = {
			recipient = scope:loved_consort
			court_position = grand_consort_court_position
		}
		ai_chance = {
			base = 0
			ai_value_modifier = {
				ai_honor = 0.1
			}
			modifier = { #More likely if zealous
				add = 15
				AND = {
					scope:loved_consort = {
						num_virtuous_traits >= 1
						num_sinful_traits = 0
					}
					has_trait = zealous
				}
			}
			modifier = { #More likely if just
				add = 15
				AND = {
					has_trait = just
					NOT = { has_imprisonment_reason = scope:loved_consort }
				}
			}
			modifier = { #More likely if high opinion of the concubine
				add = 10
				opinion = {
					target = scope:loved_consort
					value >= high_positive_opinion
				}
			}
			modifier = { #More likely if the concubine is the player heir's parent
				add = 30
				scope:loved_consort = {
					OR = {
						any_child = {
							OR = {
								this = root.player_heir
								any_spouse = {
									OR = {
										is_powerful_vassal_of = root
										is_councillor_of = root
										highest_held_title_tier >= tier_kingdom
										is_liege_or_above_of = root
									}
								}
							}
						}
						any_close_family_member = {
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = { #Soulmate
				has_relation_soulmate = scope:loved_consort
				add = 20
			}
			modifier = { #Lover
				has_relation_lover = scope:loved_consort
				add = 10
			}
			modifier = { #BFF
				has_relation_best_friend = scope:loved_consort
				add = 15
			}
			modifier = { #Friend
				has_relation_friend = scope:loved_consort
				add = 10
			}
			modifier = { #Many kids!
				scope:loved_consort = {
					any_child = {
						even_if_dead = yes
						count >= 3
					}
				}
				add = 20
			}
			modifier = { #Special kids!
				scope:loved_consort = {
					any_child = {
						OR = {
							has_trait = twin
							has_trait = reincarnation
						}
					}
				}
				add = 20
			}
			modifier = { #Reincarnation
				scope:loved_consort = {
					has_trait = reincarnation
				}
				add = 20
			}
			modifier = { #Powerful relatives with at least one child
				scope:loved_consort = {
					AND = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								highest_held_title_tier >= tier_kingdom
							}
						}
						any_child = {
							even_if_dead = yes
							count >= 1
						}
					}
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:loved_consort = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Culture
				culture = scope:loved_consort.culture
				add = 10
			}
			modifier = { #Aptitude
				scope:loved_consort.aptitude:grand_consort_court_position >= 3
				add = 10
			}
			modifier = { #Aptitude
				scope:loved_consort.aptitude:grand_consort_court_position >= 4
				add = 5
			}
			modifier = { #Aptitude
				scope:loved_consort.aptitude:grand_consort_court_position <= 2
				add = -20
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:loved_consort = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:loved_consort = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = 20
			}
		}
	}
	
	option = { # Another time
		name = harem_politics.0004.c
		stress_impact = {
			generous = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		if = {
			limit = {
				has_trait = just
				NOR = {
					has_imprisonment_reason = scope:loved_consort
					scope:loved_consort = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		if = {
			limit = {
				scope:loved_consort = {
					OR = {
						has_trait = ambitious
						has_trait = arrogant
						has_trait = greedy
						has_trait = impatient
					}
					hp_accepts_harems = yes
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
				}
			}
			scope:loved_consort = {
				add_opinion = {
					target = root
					modifier = impatiently_waiting_opinion
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.2
			}
			modifier = { #More likely if they have sinful traits
				add = 10
				AND = {
					scope:loved_consort = {
						num_virtuous_traits = 0
						num_sinful_traits >= 1
					}
					has_trait = zealous
				}
			}
			modifier = { #More likely if just
				add = 20
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:loved_consort
				}
			}
			modifier = { #Less likely if generous
				add = -30
				OR = {
					has_trait = generous
					has_trait = forgiving
					has_trait = compassionate
				}
			}
			modifier = { #More likely if low opinion of the concubine
				add = 15
				opinion = {
					target = scope:loved_consort
					value <= low_negative_opinion
				}
			}
			modifier = { #More likely if enemy
				add = 100
				OR = {
					has_relation_nemesis = scope:loved_consort
					has_relation_rival = scope:loved_consort
				}
			}
			modifier = { #Lowborn
				scope:loved_consort = {
					is_lowborn = yes
				}
				add = 5
			}
			modifier = { # Faith considerations
				NOT = { faith = scope:loved_consort.faith }				
				add = 20
			}
		}
	}
	after = {
		add_character_flag = {
			flag = flag_had_promote_consort_event
			months = 18
		}
		scope:loved_consort = {
			add_character_flag = {
				flag = flag_considered_consort
				years = 5
			}
		}
	}
}

##################################
##Considering demoting a consort##
##################################
scripted_trigger harem_politics_valid_demotion_consort_trigger = {
	is_physically_able_ai_adult = yes
	harem_politics_beloved_consort_trigger = no
	NOR = {
		has_character_flag = flag_considered_consort
		
		has_strong_hook = root
		has_character_flag = flag_pleaded_for
		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_lover = root
		has_relation_soulmate = root
		any_close_family_member = {
			is_liege_or_above_of = root
		}

		has_character_modifier = favor_boost_modifier

		has_strong_hook = root
	}
	is_courtier_of = root
	save_temporary_scope_as = criminal_consort
	OR = {
		has_relation_rival = root
		has_relation_nemesis = root
		any_secret = { 
			is_known_by = root
			is_criminal_for = secret_owner
		}
		AND = {
			num_sinful_traits >= 2
			num_virtuous_traits = 0
		}
		AND = {
			has_trait = witch
			trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = deviant
			trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = sodomite
			trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = fornicator
			trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = adulterer
			trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = incestuous
			trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = kinslayer_1
			trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
		}
		AND = {
			has_trait = kinslayer_2
			trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
		}
		AND = {
			has_trait = kinslayer_3
			trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
		}
		AND = {
			has_trait = deviant
			trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
		AND = {
			has_trait = cannibal
			trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:criminal_consort }
		}
	}
}

harem_politics.0005 = {
	type = character_event
	title = harem_politics.0004.t
	desc = {
		desc = harem_politics.0005.start.desc
		first_valid = {
			triggered_desc = { #Main husband
				trigger = {
					any_spouse = {
						count >= 2
					}
					primary_spouse = {
						is_male = yes
						this = scope:sinful_spouse
					}
				}
				desc = harem_politics.0005.main_spouse_m.desc
			}
			triggered_desc = { #Main wife
				trigger = {
					any_spouse = {
						count >= 2
					}
					primary_spouse = {
						is_male = no
						this = scope:sinful_spouse
					}
				}
				desc = harem_politics.0005.main_spouse_f.desc
			}
			triggered_desc = { #Grand Consort
				trigger = {
					scope:sinful_spouse = {
						has_court_position = grand_consort_court_position
					}
				}
				desc = harem_politics.0005.gc.desc
			}
			triggered_desc = {
				desc = harem_politics.0005.generic.desc
			}
		}
		desc = harem_politics.0005.end.desc
	}
	theme = family
	
	lower_center_portrait = { 	
		character = scope:sinful_spouse
	}
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	trigger = {
		OR = {
			AND = {
				any_spouse = {
					harem_politics_valid_demotion_consort_trigger = yes
					save_temporary_scope_as = reference_consort
				}
				is_character_interaction_valid = {
					recipient = scope:reference_consort
					interaction = demote_spouse_interaction
				}
			}
			AND = {
				any_consort = {
					has_court_position = grand_consort_court_position
					harem_politics_valid_demotion_consort_trigger = yes
				}
			}
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOR = {
			culture = {
				has_cultural_parameter = cannot_divorce
			}
			faith = {
				OR = {	
					has_doctrine = doctrine_divorce_disallowed
					AND = {
						has_doctrine = doctrine_divorce_approval
						has_doctrine = doctrine_spiritual_head
						exists = religious_head
					}
					AND = {
						has_doctrine = doctrine_divorce_approval
						exists = scope:actor.house
						exists = scope:actor.house.house_head
						is_house_head = no
					}
				}
			}

			has_character_flag = flag_had_demote_consort_event
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				harem_politics_valid_demotion_consort_trigger = yes
			}
			add_to_list = potential_concubines_list
		}
		
		random_in_list = {
			list = potential_concubines_list
			weight = {
				base = 30
				modifier = { #No connections
					NOT = {
						any_close_family_member = {
							is_allied_to = root
						}
					}
					add = 20
				}
				modifier = { #Rival
					has_relation_rival = root
					add = 20
				}
				modifier = { #Nemesis
					has_relation_nemesis = root
					add = 50
				}
				modifier = { #Secret
				any_secret = { 
					is_known_by = root
					is_criminal_for = secret_owner
				}
					add = 20
				}
				modifier = { #Sinner
					AND = {
						num_sinful_traits >= 2
						num_virtuous_traits = 0
					}
					add = 15
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = -15
				}
				modifier = { #Unfavored consort
					has_character_modifier = unfavored_consort_modifier
					add = 10
				}
				modifier = { #Unfavored consort
					has_character_modifier = forgotten_consort_modifier
					add = 20
				}
				modifier = { #No kids
					any_child = {
						even_if_dead = yes
						count = 0
					}
					add = 10
				}
				modifier = { #More likely if the consort is not the player heir's parent
					add = 20
					any_child = {
						NOR = {
							this = root.player_heir
							any_spouse = {
								OR = {
									is_powerful_vassal_of = root
									is_councillor_of = root
									highest_held_title_tier >= tier_kingdom
								}
							}
						}
					}
				}
				modifier = { #Weak relatives
					any_close_family_member = {
						NOR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
						}
					}
					add = 30
				}
				modifier = { #No connections
					NOT = {
						any_close_family_member = {
							is_vassal_of = root
						}
					}
					add = 10
				}
				modifier = { #No connections
					is_lowborn = yes
					add = 10
				}
				modifier = { #The PS is more important
					this = root.primary_spouse
					add = -20
				}
				modifier = { #The GC is more important
					has_court_position = grand_consort_court_position
					add = -10
				}
				modifier = { #They were already demoted
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = -25
				}
				modifier = { #Known criminal
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = this }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = this }
						}
					}
					add = 20
				}
			}
			save_scope_as = sinful_spouse
		}
	}
	
	option = { # Dismiss GC
		name = harem_politics.0005.a
		trigger = {
			scope:sinful_spouse = {
				has_court_position = grand_consort_court_position
				is_courtier_of = root
				harem_politics_valid_demotion_consort_trigger = yes
			}
		}
		revoke_court_position = {
			recipient = scope:sinful_spouse
			court_position = grand_consort_court_position
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.1
			}
			modifier = { #More likely if criminal
				add = 30
				has_imprisonment_reason = scope:sinful_spouse
			}
			modifier = { #They were already demoted
				scope:sinful_spouse = {
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
				}
				add = -10
			}
			modifier = { #Just and criminal
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:sinful_spouse
				}
				add = 15
			}
			modifier = { #Zealous
				AND = {
					has_trait = zealous
					scope:sinful_spouse = {
						AND = {
							num_sinful_traits >= 2
							num_virtuous_traits = 0
						}
					}
				}
				add = 15
			}
			modifier = { #Stress management
				add = -30
				OR = {
					has_trait = forgiving
					has_trait = compassionate
				}
			}
			modifier = { #More likely if low opinion
				add = 15
				opinion = {
					target = scope:sinful_spouse
					value <= low_negative_opinion
				}
			}
			modifier = { #Culture
				NOT = { culture = scope:sinful_spouse.culture }
				add = 10
			}
			modifier = { #Faith
				NOT = { faith = scope:sinful_spouse.faith }
				add = 15
			}
			
			modifier = { #Rival
				has_relation_rival = scope:sinful_spouse
				add = 30
			}
			modifier = { #Nemesis
				has_relation_nemesis = scope:sinful_spouse
				add = 60
			}
			modifier = { #Secret
				scope:sinful_spouse = {
					any_secret = { 
						is_known_by = root
						is_criminal_for = secret_owner
					}
				}
				add = 20
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:sinful_spouse = {
					has_character_modifier = favored_consort_modifier
				}
				add = -15
			}
			
			modifier = { #No kids
				scope:sinful_spouse = {
					any_child = {
						even_if_dead = yes
						count = 0
					}
				}
				add = 10
			}
			modifier = { #No connections
				NOT = {
					scope:sinful_spouse = {
						any_close_family_member = {
							is_vassal_of = root
						}
					}
				}
				add = 10
			}
			modifier = { #Lowborn
				scope:sinful_spouse = {
					is_lowborn = yes
				}
				add = 5
			}
			modifier = { #Scolded consort
				scope:sinful_spouse = {
					has_character_flag = flag_scolded_consort
				}
				add = 10
			}
			modifier = { #Less if they come from a prominent family and innocent
				scope:sinful_spouse = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
						}
					}
				}
				add = -20
			}
			modifier = { #Aptitude
				scope:sinful_spouse.aptitude:grand_consort_court_position >= 3
				add = -10
			}
			modifier = { #Aptitude
				scope:sinful_spouse.aptitude:grand_consort_court_position >= 4
				add = -10
			}
			modifier = { #Aptitude
				scope:sinful_spouse.aptitude:grand_consort_court_position <= 2
				add = 20
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = -20
			}
			modifier = { #Alliances
				scope:sinful_spouse = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -15
			}
		}
	}
	
	option = { # Demote them
		name = harem_politics.0005.b
		trigger = {
			scope:sinful_spouse = {
				is_spouse_of = root
			}
			is_character_interaction_valid = {
				recipient = scope:sinful_spouse
				interaction = demote_spouse_interaction
			}
		}
		run_interaction = {
			interaction = demote_spouse_interaction
			actor = scope:harem_liege
			recipient = scope:sinful_spouse
			execute_threshold = accept
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			vengeful = minor_stress_impact_loss
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.1
			}
			modifier = { #More likely if criminal
				add = 30
				has_imprisonment_reason = scope:sinful_spouse
			}
			modifier = { #They were already demoted
				scope:sinful_spouse = {
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
				}
				add = -10
			}
			modifier = { #Just and criminal
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:sinful_spouse
				}
				add = 15
			}
			modifier = { #Zealous
				AND = {
					has_trait = zealous
					scope:sinful_spouse = {
						AND = {
							num_sinful_traits >= 2
							num_virtuous_traits = 0
						}
					}
				}
				add = 15
			}
			modifier = { #Stress management
				add = -30
				OR = {
					has_trait = forgiving
					has_trait = compassionate
				}
			}
			modifier = { #More likely if low opinion
				add = 15
				opinion = {
					target = scope:sinful_spouse
					value <= low_negative_opinion
				}
			}
			modifier = { #Culture
				NOT = { culture = scope:sinful_spouse.culture }
				add = 10
			}
			modifier = { #Faith
				NOT = { faith = scope:sinful_spouse.faith }
				add = 15
			}
			
			modifier = { #Rival
				has_relation_rival = scope:sinful_spouse
				add = 30
			}
			modifier = { #Nemesis
				has_relation_nemesis = scope:sinful_spouse
				add = 60
			}
			modifier = { #Secret
				scope:sinful_spouse = {
					any_secret = { 
						is_known_by = root
						is_criminal_for = secret_owner
					}
				}
				add = 20
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:sinful_spouse = {
					has_character_modifier = favored_consort_modifier
				}
				add = -15
			}
			
			modifier = { #No kids
				scope:sinful_spouse = {
					any_child = {
						even_if_dead = yes
						count = 0
					}
				}
				add = 10
			}
			modifier = { #No connections
				NOT = {
					scope:sinful_spouse = {
						any_close_family_member = {
							is_vassal_of = root
						}
					}
				}
				add = 10
			}
			modifier = { #Lowborn
				scope:sinful_spouse = {
					is_lowborn = yes
				}
				add = 5
			}
			modifier = { #Scolded consort
				scope:sinful_spouse = {
					has_character_flag = flag_scolded_consort
				}
				add = 10
			}
			modifier = { #Less if they come from a prominent family and innocent
				scope:sinful_spouse = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
						}
					}
				}
				add = -20
			}
			
			modifier = { #Alliances
				scope:sinful_spouse = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -15
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = -20
			}
		}
	}
	
	option = { # Arrest them
		name = harem_politics.0005.c
		save_scope_as = actor
		scope:sinful_spouse = {
			if = { #If they're a GC, demote them
				limit = {
					has_court_position = grand_consort_court_position
				}
				save_scope_as = employee
				root = {
					save_scope_as = liege
				}
				grand_consort_revoked_court_position_effect = yes
			}
			else_if = {
				limit = {
					NOT = { has_court_position = grand_consort_court_position }
				}
				if = {
					limit = {
						has_character_modifier = favor_boost_modifier
					}
					calyver_stop_favor_boost_event_effect = {
						HAREM_LIEGE = root
						CONSORT = scope:sinful_spouse
					}
				}
				calyver_favor_big_loss_effect = yes
				root = {
					if = {
						limit = {
							has_trait = just
							OR = {
								has_imprisonment_reason = scope:sinful_spouse
								scope:sinful_spouse = {
									any_secret = { 
										is_known_by = root
										is_criminal_for = secret_owner
									}
								}
							}
						}
						stress_impact = {
							just = minor_stress_impact_loss
						}
					}
					stress_impact = {
						forgiving = minor_stress_impact_gain
						compassionate = minor_stress_impact_gain
					}
				}
			}
			if = {
				limit = { 
					can_set_relation_potential_rival_trigger = { CHARACTER = root }
				}
				set_relation_potential_rival = root
			}
			save_scope_as = recipient
		}
		imprison = {
			target = scope:sinful_spouse
			type = house_arrest
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = 0.1
			}
			modifier = { #More likely if criminal
				add = 30
				has_imprisonment_reason = scope:sinful_spouse
			}
			modifier = { #They were already demoted
				scope:sinful_spouse = {
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
				}
				add = -10
			}
			modifier = { #Just and criminal
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:sinful_spouse
				}
				add = 15
			}
			modifier = { #Stress management
				add = -30
				OR = {
					has_trait = forgiving
					has_trait = compassionate
				}
			}
			modifier = { #More likely if low opinion
				add = 15
				opinion = {
					target = scope:sinful_spouse
					value <= low_negative_opinion
				}
			}
			modifier = { #Culture
				NOT = { culture = scope:sinful_spouse.culture }
				add = 10
			}
			modifier = { #Faith
				NOT = { faith = scope:sinful_spouse.faith }
				add = 15
			}
			
			modifier = { #Rival
				has_relation_rival = scope:sinful_spouse
				add = 30
			}
			modifier = { #Nemesis
				has_relation_nemesis = scope:sinful_spouse
				add = 60
			}
			modifier = { #Secret
				scope:sinful_spouse = {
					any_secret = { 
						is_known_by = root
						is_criminal_for = secret_owner
					}
				}
				add = 20
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Unfavored consort
				scope:sinful_spouse = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}
			modifier = { #Favored consort
				scope:sinful_spouse = {
					has_character_modifier = favored_consort_modifier
				}
				add = -15
			}
			
			modifier = { #No kids
				scope:sinful_spouse = {
					any_child = {
						even_if_dead = yes
						count = 0
					}
				}
				add = 10
			}
			modifier = { #No connections
				NOT = {
					scope:sinful_spouse = {
						any_close_family_member = {
							is_vassal_of = root
						}
					}
				}
				add = 10
			}
			modifier = { #Lowborn
				scope:sinful_spouse = {
					is_lowborn = yes
				}
				add = 5
			}
			modifier = { #Scolded consort
				scope:sinful_spouse = {
					has_character_flag = flag_scolded_consort
				}
				add = 10
			}
			modifier = { #Less if they come from a prominent family and innocent
				scope:sinful_spouse = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
						}
					}
				}
				add = -20
			}
			modifier = { #Alliances
				scope:sinful_spouse = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -15
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = -20
			}
		}
		trigger_event = harem_politics.1000
	}
	
	option = { # Another time
		name = harem_politics.0004.c
		if = {
			limit = {
				has_trait = just
				OR = {
					has_imprisonment_reason = scope:sinful_spouse
					scope:sinful_spouse = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		stress_impact = {
			vengeful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_honor = -0.1
			}
			modifier = { #Alliances
				scope:sinful_spouse = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = 15
			}
			modifier = { #They were already demoted
				scope:sinful_spouse = {
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
				}
				add = 10
			}
			modifier = { #Favored consort
				scope:sinful_spouse = {
					has_character_modifier = favored_consort_modifier
				}
				add = 20
			}
			modifier = { #Compassionate
				OR = {
					has_trait = compassionate
					has_trait = forgiving
				}
				add = 20
			}
			modifier = { #Vengeful
				has_trait = vengeful
				add = -20
			}
			modifier = { #Known criminal
				AND = {
					has_trait = just
					has_imprisonment_reason = scope:sinful_spouse
				}
				add = -20
			}
			
			modifier = { #Zealous
				AND = {
					has_trait = zealous
					scope:sinful_spouse = {
						AND = {
							num_sinful_traits >= 2
							num_virtuous_traits = 0
						}
					}
				}
				add = -5
			}
			modifier = { #More likely if not criminal
				add = 15
				NOT = {
					has_imprisonment_reason = scope:sinful_spouse
				}
			}
			modifier = { #More likely if high opinion
				add = 10
				opinion = {
					target = scope:sinful_spouse
					value >= low_positive_opinion
				}
			}
			
			modifier = { #Important children
				add = 20
				scope:sinful_spouse = {
					any_child = {
						this = root.player_heir
					}
				}
			}
			modifier = { #Many children
				add = 20
				scope:sinful_spouse = {
					any_child = {
						even_if_dead = yes
						count >= 4
					}
				}
			}
			modifier = { #Strong relatives
				scope:sinful_spouse = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
						}
					}
				}
				add = 20
			}
			modifier = { #Connections
				scope:sinful_spouse = {
					any_close_family_member = {
						is_vassal_of = root
					}
				}
				add = 10
			}
			modifier = { #Primary spouse
				scope:sinful_spouse = {
					this = root.primary_spouse
				}
				add = 20
			}
			modifier = { #GC
				scope:sinful_spouse = {
					has_court_position = grand_consort_court_position
				}
				add = 15
			}
			modifier = { #Soulmate
				has_relation_soulmate = scope:sinful_spouse
				add = 30
			}
			modifier = { #Lover
				has_relation_lover = scope:sinful_spouse
				add = 20
			}
			modifier = { #Friend
				has_relation_friend = scope:sinful_spouse
				add = 10
			}
			modifier = { #BFF
				has_relation_best_friend = scope:sinful_spouse
				add = 15
			}
			modifier = { #Valuable heir
				OR = {
					AND = {
						OR = {
							has_realm_law = female_only_law
							has_realm_law = female_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = no
									is_child_of = root
								}
							}
						}
					}
					AND = {
						OR = {
							has_realm_law = male_only_law
							has_realm_law = male_preference_law
						}
						scope:sinful_spouse = {
							any_child = {
								AND = {
									is_male = yes
									is_child_of = root
								}
							}
						}
					}
				}
				add = 10
			}
		}
	}

	after = {
		scope:sinful_spouse = {
			add_character_flag = {
				flag = flag_considered_consort
				years = 5
			}
		}
		add_character_flag = {
			flag = flag_had_demote_consort_event
			months = 18
		}
	}
}

################
##Orphan child##
################
scripted_trigger harem_politics_valid_orphan_child_trigger = {
	OR = {
		NOT = { exists = mother }
		NOT = { exists = father }
		mother = {
			is_alive = no
		}
		father = {
			is_alive = no
		}
	}
	is_landed_or_landless_administrative = no
	is_courtier_of = root
	is_physically_able = yes
	is_adult = no
	age >= 7
	age <= 14
	NOR = { 
		has_character_flag = considered_child_flag
		has_relation_guardian = root
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
	is_hostage = no
}

scripted_trigger harem_politics_valid_mother_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no
	age <= 50
	NOR = {
		sex_same_as = root 
		
		has_trait = ill
		has_trait = wounded
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_effect non_parent_effect = {
	random_list = {
		50 = { #Progress towards rivals
			modifier = {
				add = 15
				OR = {
					hp_accepts_concubinage = yes
					hp_accepts_polygamy = yes
				}
			}
			modifier = { #Traits
				add = 10
				harem_politics_evil_consort_trigger = yes
			}
			modifier = { #Traits
				add = 10
				has_trait = vengeful
			}
			modifier = { #Traits
				add = 10
				has_trait = ambitious
			}
			modifier = { #Traits
				add = 10
				has_trait = greedy
			}
			modifier = { #Traits
				add = 10
				has_trait = infertile
			}
			modifier = { #Age
				add = 10
				age >= 40
			}
			modifier = { #Childless
				add = 10
				any_child = {
					count = 0
				}
			}
			opinion_modifier = {
				opinion_target = scope:new_parent
				multiplier = -0.30
			}
			opinion_modifier = { #If they don't like the player, they don't want a child
				opinion_target = root
				multiplier = 0.50
			}
			if = {
				limit = { 
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:new_parent }
				}
				set_relation_potential_rival = scope:new_parent
			}
			add_opinion = {
				target = scope:new_parent
				modifier = stole_my_child_consort_opinion
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
		50 = { #Nothing
			modifier = {
				add = 15
				NOR = {
					hp_accepts_concubinage = yes
					hp_accepts_polygamy = yes
				}
			}
			modifier = { #Traits
				add = 10
				harem_politics_evil_consort_trigger = no
			}
			modifier = { #Traits
				add = 10
				has_trait = compassionate
			}
			modifier = { #Traits
				add = 10
				has_trait = forgiving
			}
			modifier = { #Traits
				add = 10
				has_trait = temperate
			}
			modifier = { #Traits
				add = 10
				has_trait = generous
			}
			modifier = { #Traits
				add = 10
				has_trait = calm
			}
			modifier = { #Child
				add = 10
				any_child = {
					count >= 1
				}
			}
			opinion_modifier = {
				opinion_target = scope:new_parent
				multiplier = 0.30
			}
			opinion_modifier = { #If they don't like player, then they're happy to not raise their child
				opinion_target = root
				multiplier = -0.50
			}
		}
	}
}

scripted_effect set_mother_consort_effect = {
	send_interface_toast = {
		left_icon = scope:new_parent
		right_icon = scope:motherless_child
		title = harem_politics.0007.tt
		scope:motherless_child = {
			if = {
				limit = { 
					scope:new_parent = {
						is_female = yes 
					}
				}
				set_mother = scope:new_parent
			}
			else = {
				set_father = scope:new_parent
			}
		}
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
	}
	scope:motherless_child = {
		add_opinion = {
			modifier = thankful_consort_opinion
			target = root
		}
		if = {
			limit = { 
				NOR = { 
					has_relation_best_friend = root
					has_relation_friend = root
				} 
			}
			set_relation_potential_friend = root
		}
		if = {
			limit = { 
				NOR = { 
					has_relation_best_friend = scope:new_parent
					has_relation_friend = scope:new_parent
				} 
			}
			set_relation_potential_friend = scope:new_parent
		}
		add_character_modifier = { 
			modifier = safe_disease_treatment_success_high_modifier 
			days = disease_treatment_short_duration 
		}
		hidden_effect = {
			change_current_weight = 15
			if = {
				limit = {
					has_any_bastard_trait_trigger = yes
				}
				remove_all_bastard_traits = yes
			}
			if = {
				limit = {
					has_trait = child_of_concubine_female
				}
				remove_trait = child_of_concubine_female
			}
			if = {
				limit = {
					has_trait = child_of_concubine_male
				}
				remove_trait = child_of_concubine_male
			}
			add_character_modifier = {
				modifier = favored_child_modifier
				years = 3
			}
		}
		if = {
			limit = { 
				scope:new_parent = {
					AND = {
						is_concubine_of = root 
						is_female = yes
						scope:motherless_child = {
							NOT = { has_trait = child_of_concubine_female }
						}
					}
				}
			}
			add_trait = child_of_concubine_female
		}
		if = {
			limit = { 
				scope:new_parent = {
					AND = {
						is_concubine_of = root 
						is_male = yes
						scope:motherless_child = {
							NOT = { has_trait = child_of_concubine_male }
						}
					}
				}
			}
			add_trait = child_of_concubine_male
		}
	}
	scope:new_parent = {
		add_opinion = {
			target = root
			modifier = thankful_consort_opinion
		}
		if = {
			limit = { 
				NOR = { 
					has_relation_lover = root
					has_relation_soulmate = root
					has_relation_potential_lover = root
				} 
			}
			set_relation_potential_lover = root
		}
		calyver_favor_medium_gain_effect = yes
		hidden_effect = {
			scope:non_parent_1 = {
				non_parent_effect = yes
			}
			scope:non_parent_2 = {
				non_parent_effect = yes
			}
		}
	}
}

harem_politics.0006 = {
	type = character_event
	title = harem_politics.0006.t
	desc = {
		desc = harem_politics.0006.start.desc
		first_valid = {
			triggered_desc = { #Man
				trigger = {
					is_male = yes
				}
				desc = harem_politics.0006.mother.desc
			}
			triggered_desc = { #Woman
				trigger = {
					is_female = yes
				}
				desc = harem_politics.0006.father.desc
			}
		}
		desc = harem_politics.0006.end.desc
	}
	theme = family
	override_background = {
		reference = corridor_night
	}
	
	left_portrait  = {
		character = scope:motherless_child
		animation = sick
	}
	right_portrait = {
		character = root
		animation = worry
	}
	
	trigger = {
		any_child = {
			harem_politics_valid_orphan_child_trigger = yes
		}
		any_consort = {
			harem_politics_valid_mother_trigger = yes
			count >= 3
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOT = { has_character_flag = had_motherless_child_event_flag }
	}

	weight_multiplier = {
		base = 1
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.35
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_child = {
			limit = {
				harem_politics_valid_orphan_child_trigger = yes
			}
			add_to_list = motherless_children_list
		}
		
		random_in_list = {
			list = motherless_children_list
			limit = {
				NOR = { 
					has_character_flag = considered_child_flag
					has_relation_ward = root
				}
			}
			weight = {
				base = 10
				modifier = { #Low-ranking children
					OR = {
						has_trait = child_of_concubine_female
						has_trait = child_of_concubine_male
						has_any_bastard_trait_trigger = yes
					}
					add = 50
				}
				modifier = { #The heir will attract bullying from other consorts
					this = root.player_heir
					add = 50
				}
			}
			save_scope_as = motherless_child
			scope:motherless_child = {
				if = {
					limit = {
						NOT = {
							has_trait = ill
						}
					}
					contract_disease_effect = { 
						DISEASE = ill 
						TREATMENT_EVENT = no 
					} 
				}
				hidden_effect = {
					change_current_weight = -20
				}
			}
		}
		
		#Court tutor
		if = {
			limit = {
				employs_court_position = court_tutor_court_position
				any_court_position_holder = {
					type = court_tutor_court_position
				}
			}
			random_court_position_holder = {
				type = court_tutor_court_position
				save_scope_as = neglecting_tutor
			}
		}
		else_if = { #Wet nurse
			limit = {
				employs_court_position = wet_nurse_court_position
				any_court_position_holder = {
					type = wet_nurse_court_position
				}
			}
			random_court_position_holder = {
				type = wet_nurse_court_position
				save_scope_as = neglecting_wet_nurse
			}
		}
	}
	
	option = { # Find a new mom
		name = harem_politics.0006.a
		trigger = { 
			any_consort = {
				harem_politics_valid_mother_trigger = yes
				count >= 3
			}
		}
		custom_tooltip = harem_politics.0006.a.tt
		trigger_event = harem_politics.0007
		stress_impact = {
			cynical = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_energy = 0.25
				ai_greed = -0.25
			}
			modifier = {	#Weight up.
				add = 30
				scope:motherless_child = {
					age >= 12
				}
			}
			modifier = {	#Weight down for stress.
				add = -35
				OR = {
					has_trait = cynical
					has_trait = callous
					has_trait = lazy
					has_trait = paranoid
				}
			}
			modifier = {	#Diligent
				add = 30
				OR = {
					has_trait = diligent
					has_trait = just
					has_trait = compassionate
				}
			}
			
			modifier = {	#Weight down opinion
				add = -25
				opinion = {
					target = scope:motherless_child
					value <= medium_negative_opinion
				}
			}
			modifier = {	#Weight down opinion
				add = 15
				opinion = {
					target = scope:motherless_child
					value >= low_positive_opinion
				}
			}
		}
	}
	
	option = { # Become the child's guardian
		name = harem_politics.0006.b
		trigger = { 
			num_of_relation_ward < 2 
			scope:motherless_child = {
				NOT = {
					has_relation_guardian = root
				}
			}
		}
		scope:motherless_child = {
			hidden_effect = {
				if = {
					limit = {
						any_relation = {
							type = guardian
							count > 0
						}
					}
					random_relation = {
						type = guardian
						save_scope_as = old_guardian
					}
					remove_relation_guardian = scope:old_guardian
				}
			}
			set_relation_guardian = root
			add_opinion = {
				modifier = thankful_consort_opinion
				target = root
			}
			hidden_effect = {
				change_current_weight = 15
				add_character_modifier = {
					modifier = favored_child_modifier
					years = 3
				}
			}
			add_character_modifier = { 
				modifier = safe_disease_treatment_success_high_modifier 
				days = disease_treatment_short_duration 
			}
			if = {
				limit = { 
					NOR = {
						has_relation_friend = root
						has_relation_best_friend = root
					}
				}
				set_relation_friend = { 
					reason = friend_motherless_child_ward_reason
					target = root 
				}
			}
		}
		
		stress_impact = {
			cynical = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_energy = 0.25
				ai_greed = -0.25
			}
			modifier = {
				add = 15
				has_trait = trusting
			}
			modifier = { #Filial
				add = 250
				OR = {
					faith = { has_doctrine = tenet_ancestor_worship }
					culture = { has_cultural_tradition = tradition_mystical_ancestors }
				}
			}
			modifier = {	#Weight up.
				add = 30
				scope:motherless_child = {
					root = { save_temporary_scope_as = compare_character }
					has_ward_guardian_education_match_compare_character_trigger = yes # same education interest
				}
			}
			modifier = {	#Weight down for stress.
				add = -30
				OR = {
					has_trait = cynical
					has_trait = callous
					has_trait = lazy
				}
			}
			modifier = {	#Diligent
				add = 30
				OR = {
					has_trait = diligent
					has_trait = just
				}
			}
			modifier = {	#Weight down opinion
				add = -20
				opinion = {
					target = scope:motherless_child
					value <= low_negative_opinion
				}
			}
			modifier = {	#Weight up opinion
				add = 20
				opinion = {
					target = scope:motherless_child
					value >= medium_positive_opinion
				}
			}
			modifier = {
				add = 25
				scope:motherless_child = root.player_heir
			}
			modifier = {
				add = 25
				OR = {
					AND = {
						scope:motherless_child  = {
							is_male = yes
						}
						is_male = yes
					}
					AND = {
						scope:motherless_child  = {
							is_female = yes
						}
						is_female = yes
					}
				}
			}
		}
	}
	
	option = { # Punish servants and find new ones
		name = harem_politics.0006.c
		scope:motherless_child = {
			add_opinion = {
				modifier = thankful_consort_opinion
				target = root
			}
			hidden_effect = {
				change_current_weight = 10
				add_character_modifier = {
					modifier = favored_child_modifier
					years = 1
				}
			}
			add_character_modifier = { 
				modifier = safe_disease_treatment_success_low_modifier 
				days = disease_treatment_short_duration 
			}
		}
		#Punish court position holders
		if = {
			limit = {
				exists = scope:neglecting_tutor
			}
			scope:neglecting_tutor = {
				add_character_modifier = {
					modifier = hunt_tasted_the_belt_modifier
					years = 2
				}
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -15
				}
			}
		}
		if = {
			limit = {
				exists = scope:neglecting_wet_nurse
			}
			scope:neglecting_wet_nurse = {
				add_character_modifier = {
					modifier = hunt_tasted_the_belt_modifier
					years = 2
				}
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -15
				}
			}
		}
		stress_impact = {
			diligent = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			just = minor_stress_impact_loss
			forgiving = minor_stress_impact_gain
			vengeful = minor_stress_impact_loss
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_greed = 0.25
			}
			modifier = {	#Weight up.
				add = 30
				scope:motherless_child = {
					root = { save_temporary_scope_as = compare_character }
					has_ward_guardian_education_match_compare_character_trigger = yes # same education interest
				}
			}
			modifier = {	#Weight down for stress.
				add = -25
				OR = {
					has_trait = compassionate
					has_trait = forgiving
					has_trait = diligent
				}
			}
			modifier = {	#Weight down for stress.
				add = 25
				OR = {
					has_trait = just
					has_trait = vengeful
				}
			}
			modifier = {	#Weight down opinion
				add = 15
				opinion = {
					target = scope:motherless_child
					value <= low_negative_opinion
				}
			}
			modifier = {	#Weight up opinion
				add = 20
				opinion = {
					target = scope:motherless_child
					value <= medium_negative_opinion
				}
			}
			modifier = {	#Weight down opinion
				add = -15
				opinion = {
					target = scope:motherless_child
					value >= low_positive_opinion
				}
			}
			modifier = {	#Player heir
				add = -15
				scope:motherless_child = root.player_heir
			}
			modifier = {	#Toutor
				exists = scope:neglecting_tutor
				scope:neglecting_tutor = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_close_family_of = root
							is_liege_or_above_of = root
							this = root
						}
					}
				}
				add = -30
			}
		}
	}
	after = {
		add_character_flag = {
			flag = had_motherless_child_event_flag
			years = 25
		}
		scope:motherless_child = {
			add_character_flag = {
				flag = considered_child_flag
			}
		}
	}
}

harem_politics.0007 = {
	type = character_event
	title = harem_politics.0007.t
	desc = {
		desc = harem_politics.0007.start.desc
		first_valid = {
			triggered_desc = { #Man
				trigger = {
					is_male = yes
				}
				desc = harem_politics.0007.mother.desc
			}
			triggered_desc = { #Woman
				trigger = {
					is_female = yes
				}
				desc = harem_politics.0007.father.desc
			}
		}
		desc = harem_politics.0007.end.desc
	}
	theme = family
	
	left_portrait  = {
		character = scope:mommy_1
		animation = flirtation_left
	}
	right_portrait = {
		character = scope:motherless_child
		animation = sick
	}
	lower_left_portrait = {
		character = scope:mommy_2
	}
	lower_right_portrait  = {
		character = scope:mommy_3
	}
	
	trigger = {
		
	}
	
	immediate = {
		every_consort = {
			limit = {
				harem_politics_valid_mother_trigger = yes
			}
			add_to_list = mother_candidate_list
		}
		
		random_in_list = {
			list = mother_candidate_list
			weight = {
				base = 10
				modifier = { #The main spouse
					this = root.primary_spouse
					add = 150
				}
				modifier = { #Grand Consort
					has_court_position = grand_consort_court_position
					add = 50
				}
				modifier = { #Spouses rank higher
					is_spouse_of = root
					add = 20
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 50
				}
				modifier = { #Lover
					has_relation_lover = root
					add = 25
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Friends
					has_relation_friend = root
					add = 10
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				modifier = { #Favored consort
					has_character_modifier = beloved_consort_modifier
					add = 25
				}
				modifier = { #Haters
					OR = {
						has_relation_rival = root
						has_relation_nemesis = root
					}
					add = -50
				}
				modifier = { #Good background
					is_lowborn = no
					add = 10
				}
				modifier = { #Nice contacts
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Good contacts
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 1
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 2
					}
					add = 5
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 4
					}
					add = 5
				}
				
				modifier = { #Traits
					add = 10
					has_trait = forgiving
				}
				modifier = { #Traits
					add = 10
					has_trait = compassionate
				}
				modifier = { #Traits
					add = 10
					has_trait = just
				}
				modifier = { #Traits
					add = 10
					has_trait = diligent
				}
				modifier = { #Traits
					add = 10
					has_trait = temperate
				}
				modifier = { #Traits
					add = 10
					has_trait = patient
				}
				modifier = { #Traits
					add = 10
					has_trait = honest
				}

				modifier = { #Traits
					add = -10
					has_trait = deceitful
				}
				modifier = { #Traits
					add = -10
					has_trait = craven
				}
				modifier = { #Traits
					add = -15
					has_trait = wrathful
				}
				modifier = { #Traits
					add = -10
					has_trait = lazy
				}
				modifier = { #Traits
					add = -15
					has_trait = vengeful
				}
				modifier = { #Traits
					add = -10
					has_trait = arrogant
				}
				modifier = { #Traits
					add = -15
					has_trait = arbitrary
				}
				modifier = { #Traits
					add = -15
					has_trait = impatient
				}
				modifier = { #Traits
					add = -10
					has_trait = gluttonous
				}
				modifier = { #Traits
					add = -15
					has_trait = sadistic
				}
				modifier = { #Traits
					add = -15
					has_trait = callous
				}
				modifier = { #Traits
					add = -10
					has_trait = fickle
				}
				
				modifier = { #Faith
					faith = root.faith
					add = 25
				}
				modifier = { #Culture
					culture = root.culture
					add = 10
				}
				modifier = { #Skills
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
					add = 20
				}
				modifier = { #Demoted consorts
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = -100
				}
				modifier = {
					add = 30
					opinion = {
						target = root
						value >= 0
					}
				}
			}
			save_scope_as = mommy_1
		}
		
		random_in_list = {
			list = mother_candidate_list
			limit = {
				NOT = {
					this = scope:mommy_1
				}
			}
			weight = {
				base = 10
				modifier = { #The main spouse
					this = root.primary_spouse
					add = 200
				}
				modifier = { #Grand Consort
					has_court_position = grand_consort_court_position
					add = 100
				}
				modifier = { #Spouses rank higher
					is_spouse_of = root
					add = 40
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 50
				}
				modifier = { #Lover
					has_relation_lover = root
					add = 25
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Friends
					has_relation_friend = root
					add = 10
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				modifier = { #Haters
					OR = {
						has_character_modifier = unfavored_consort_modifier
						has_relation_rival = root
						has_relation_nemesis = root
					}
					add = -50
				}
				modifier = { #Good background
					is_lowborn = no
					add = 10
				}
				modifier = { #Nice contacts
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Good contacts
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 1
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 2
					}
					add = 5
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 4
					}
					add = 5
				}
				
				modifier = { #Traits
					add = 10
					has_trait = forgiving
				}
				modifier = { #Traits
					add = 10
					has_trait = compassionate
				}
				modifier = { #Traits
					add = 10
					has_trait = just
				}
				modifier = { #Traits
					add = 10
					has_trait = diligent
				}
				modifier = { #Traits
					add = 10
					has_trait = temperate
				}
				modifier = { #Traits
					add = 10
					has_trait = patient
				}
				modifier = { #Traits
					add = 10
					has_trait = honest
				}

				modifier = { #Traits
					add = -10
					has_trait = deceitful
				}
				modifier = { #Traits
					add = -10
					has_trait = craven
				}
				modifier = { #Traits
					add = -15
					has_trait = wrathful
				}
				modifier = { #Traits
					add = -10
					has_trait = lazy
				}
				modifier = { #Traits
					add = -15
					has_trait = vengeful
				}
				modifier = { #Traits
					add = -10
					has_trait = arrogant
				}
				modifier = { #Traits
					add = -15
					has_trait = arbitrary
				}
				modifier = { #Traits
					add = -15
					has_trait = impatient
				}
				modifier = { #Traits
					add = -10
					has_trait = gluttonous
				}
				modifier = { #Traits
					add = -15
					has_trait = sadistic
				}
				modifier = { #Traits
					add = -15
					has_trait = callous
				}
				modifier = { #Traits
					add = -10
					has_trait = fickle
				}

				modifier = { #Faith
					faith = root.faith
					add = 25
				}
				modifier = { #Culture
					culture = root.culture
					add = 10
				}
				modifier = { #Skills
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
					add = 20
				}
				modifier = { #Demoted consorts
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = -100
				}
				modifier = {
					add = 30
					opinion = {
						target = root
						value >= 0
					}
				}
			}
			save_scope_as = mommy_2
		}
		
		random_in_list = {
			list = mother_candidate_list
			limit = {
				NOR = {
					this = scope:mommy_1
					this = scope:mommy_2
				}
			}
			weight = {
				base = 10
				modifier = { #The main spouse
					this = root.primary_spouse
					add = 200
				}
				modifier = { #Grand Consort
					has_court_position = grand_consort_court_position
					add = 100
				}
				modifier = { #Spouses rank higher
					is_spouse_of = root
					add = 40
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 50
				}
				modifier = { #Lover
					has_relation_lover = root
					add = 25
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Friends
					has_relation_friend = root
					add = 10
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				modifier = { #Haters
					OR = {
						has_character_modifier = unfavored_consort_modifier
						has_relation_rival = root
						has_relation_nemesis = root
					}
					add = -50
				}
				modifier = { #Good background
					is_lowborn = no
					add = 10
				}
				modifier = { #Nice contacts
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 10
				}
				modifier = { #Good contacts
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 1
					}
					add = 20
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 2
					}
					add = 5
				}
				modifier = { #Kids
					any_child = {
						even_if_dead = yes
						count >= 4
					}
					add = 5
				}

				modifier = { #Traits
					add = 10
					has_trait = forgiving
				}
				modifier = { #Traits
					add = 10
					has_trait = compassionate
				}
				modifier = { #Traits
					add = 10
					has_trait = just
				}
				modifier = { #Traits
					add = 10
					has_trait = diligent
				}
				modifier = { #Traits
					add = 10
					has_trait = temperate
				}
				modifier = { #Traits
					add = 10
					has_trait = patient
				}
				modifier = { #Traits
					add = 10
					has_trait = honest
				}

				modifier = { #Traits
					add = -10
					has_trait = deceitful
				}
				modifier = { #Traits
					add = -10
					has_trait = craven
				}
				modifier = { #Traits
					add = -15
					has_trait = wrathful
				}
				modifier = { #Traits
					add = -10
					has_trait = lazy
				}
				modifier = { #Traits
					add = -15
					has_trait = vengeful
				}
				modifier = { #Traits
					add = -10
					has_trait = arrogant
				}
				modifier = { #Traits
					add = -15
					has_trait = arbitrary
				}
				modifier = { #Traits
					add = -15
					has_trait = impatient
				}
				modifier = { #Traits
					add = -10
					has_trait = gluttonous
				}
				modifier = { #Traits
					add = -15
					has_trait = sadistic
				}
				modifier = { #Traits
					add = -15
					has_trait = callous
				}
				modifier = { #Traits
					add = -10
					has_trait = fickle
				}

				modifier = { #Faith
					faith = root.faith
					add = 25
				}
				modifier = { #Culture
					culture = root.culture
					add = 10
				}
				modifier = { #Skills
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
					add = 20
				}
				modifier = { #Demoted consorts
					OR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = -100
				}
				modifier = {
					add = 30
					opinion = {
						target = root
						value >= 0
					}
				}
			}
			save_scope_as = mommy_3
		}
	}
	
	option = { # Mommy_1 is chosen
		name = harem_politics.0007.a
		scope:mommy_1 = {
			save_scope_as = new_parent
		}
		scope:mommy_2 = {
			save_scope_as = non_parent_1
		}
		scope:mommy_3 = {
			save_scope_as = non_parent_2
		}
		set_mother_consort_effect = yes
		ai_chance = {
			base = 5
			modifier = {
				add = -35
				has_trait = paranoid
			}
			modifier = {
				add = 15
				has_relation_friend = scope:mommy_1
			}
			modifier = {
				add = 25
				has_relation_best_friend = scope:mommy_1
			}
			modifier = {
				add = 20
				has_relation_lover = scope:mommy_1
			}
			modifier = {
				add = 30
				has_relation_soulmate = scope:mommy_1
			}
			modifier = {
				add = -30
				OR = {
					has_relation_nemesis = scope:mommy_1
					has_relation_rival = scope:mommy_1
					scope:mommy_1 = {
						OR = {
							has_character_modifier = demoted_primary_spouse_modifier
							has_character_modifier = demoted_spouse_modifier
							has_character_modifier = unfavored_consort_modifier
						}
					}
				}
			}
			modifier = {
				add = 10
				scope:mommy_1 = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:mommy_1 = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_1 = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_1 = {
					is_spouse_of = root
				}
			}
			modifier = {
				add = 10
				scope:mommy_1 = root.primary_spouse
			}
			modifier = {
				add = 10
				scope:mommy_1 = {
					any_child = {
						count >= 1
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_1 = {
					any_child = {
						count >= 2
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_1 = {
					any_child = {
						count >= 3
					}
				}
			}
			modifier = {
				add = 20
				scope:mommy_1 = {
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
				}
			}
			modifier = {
				add = -30
				scope:mommy_1 = {
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
						}
					}
				}
			}

			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = forgiving
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = compassionate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = just
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = diligent
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = temperate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = patient
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_1 = {
					has_trait = honest
				}
			}

			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = deceitful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = craven
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = wrathful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = lazy
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = vengeful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = arrogant
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = arbitrary
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = impatient
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = gluttonous
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = sadistic
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_1 = {
					has_trait = callous
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_1 = {
					has_trait = fickle
				}
			}

			modifier = { #Background
				add = 15
				scope:mommy_1 = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = {
				add = -35
				NOT = { faith = scope:mommy_1.faith }
			}
		}
	}
	
	option = { # Mommy_2 is chosen
		name = harem_politics.0007.b
		scope:mommy_1 = {
			save_scope_as = non_parent_1
		}
		scope:mommy_2 = {
			save_scope_as = new_parent
		}
		scope:mommy_3 = {
			save_scope_as = non_parent_2
		}
		set_mother_consort_effect = yes
		ai_chance = {
			base = 5
			modifier = {
				add = -35
				has_trait = paranoid
			}
			modifier = {
				add = -35
				NOT = { faith = scope:mommy_2.faith }
			}
			modifier = {
				add = 15
				has_relation_friend = scope:mommy_2
			}
			modifier = {
				add = 25
				has_relation_best_friend = scope:mommy_2
			}
			modifier = {
				add = 20
				has_relation_lover = scope:mommy_2
			}
			modifier = {
				add = 30
				has_relation_soulmate = scope:mommy_2
			}
			modifier = {
				add = -30
				OR = {
					has_relation_nemesis = scope:mommy_2
					has_relation_rival = scope:mommy_2
					scope:mommy_2 = {
						OR = {
							has_character_modifier = demoted_primary_spouse_modifier
							has_character_modifier = demoted_spouse_modifier
							has_character_modifier = unfavored_consort_modifier
						}
					}
				}
			}
			modifier = {
				add = 10
				scope:mommy_2 = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:mommy_2 = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_2 = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_2 = {
					is_spouse_of = root
				}
			}
			modifier = {
				add = 10
				scope:mommy_2 = root.primary_spouse
			}
			modifier = {
				add = 10
				scope:mommy_2 = {
					any_child = {
						count >= 1
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_2 = {
					any_child = {
						count >= 2
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_2 = {
					any_child = {
						count >= 3
					}
				}
			}
			modifier = {
				add = 20
				scope:mommy_2 = {
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
				}
			}
			modifier = {
				add = -30
				scope:mommy_2 = {
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
						}
					}
				}
			}
			
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = forgiving
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = compassionate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = just
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = diligent
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = temperate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = patient
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_2 = {
					has_trait = honest
				}
			}

			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = deceitful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = craven
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = wrathful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = lazy
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = vengeful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = arrogant
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = arbitrary
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = impatient
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = gluttonous
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = sadistic
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_2 = {
					has_trait = callous
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_2 = {
					has_trait = fickle
				}
			}

			modifier = { #Background
				add = 15
				scope:mommy_2 = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
				}
			}
		}
	}
	
	option = { # Mommy_3 is chosen
		name = harem_politics.0007.c
		scope:mommy_1 = {
			save_scope_as = non_parent_1
		}
		scope:mommy_2 = {
			save_scope_as = non_parent_2
		}
		scope:mommy_3 = {
			save_scope_as = new_parent
		}
		set_mother_consort_effect = yes
		ai_chance = {
			base = 5
			modifier = {
				add = -35
				has_trait = paranoid
			}
			modifier = {
				add = -35
				NOT = { faith = scope:mommy_3.faith }
			}
			modifier = {
				add = 15
				has_relation_friend = scope:mommy_3
			}
			modifier = {
				add = 25
				has_relation_best_friend = scope:mommy_3
			}
			modifier = {
				add = 20
				has_relation_lover = scope:mommy_3
			}
			modifier = {
				add = 30
				has_relation_soulmate = scope:mommy_3
			}
			modifier = {
				add = -30
				OR = {
					has_relation_nemesis = scope:mommy_3
					has_relation_rival = scope:mommy_3
					scope:mommy_3 = {
						OR = {
							has_character_modifier = demoted_primary_spouse_modifier
							has_character_modifier = demoted_spouse_modifier
							has_character_modifier = unfavored_consort_modifier
						}
					}
				}
			}
			modifier = {
				add = 10
				scope:mommy_3 = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:mommy_3 = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_3 = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 15
				scope:mommy_3 = {
					is_spouse_of = root
				}
			}
			modifier = {
				add = 10
				scope:mommy_3 = root.primary_spouse
			}
			modifier = {
				add = 10
				scope:mommy_3 = {
					any_child = {
						count >= 1
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_3 = {
					any_child = {
						count >= 2
					}
				}
			}
			modifier = {
				add = 5
				scope:mommy_3 = {
					any_child = {
						count >= 3
					}
				}
			}
			modifier = {
				add = 20
				scope:mommy_3 = {
					OR = {
						diplomacy >= 13
						stewardship >= 13
						learning >= 13
					}
				}
			}
			modifier = {
				add = -30
				scope:mommy_3 = {
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
						}
					}
				}
			}
			
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = forgiving
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = compassionate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = just
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = diligent
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = temperate
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = patient
				}
			}
			modifier = { #Traits
				add = 10
				scope:mommy_3 = {
					has_trait = honest
				}
			}

			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = deceitful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = craven
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = wrathful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = lazy
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = vengeful
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = arrogant
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = arbitrary
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = impatient
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = gluttonous
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = sadistic
				}
			}
			modifier = { #Traits
				add = -15
				scope:mommy_3 = {
					has_trait = callous
				}
			}
			modifier = { #Traits
				add = -10
				scope:mommy_3 = {
					has_trait = fickle
				}
			}

			modifier = { #Background
				add = 15
				scope:mommy_3 = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							highest_held_title_tier >= tier_kingdom
							is_liege_or_above_of = root
						}
					}
				}
			}
		}
	}
	
	option = { # Let the child decide
		name = harem_politics.0007.d
		custom_tooltip = harem_politics.0007.d.tt
		hidden_effect = {
			random = {
				chance = 100
				random_list = {
					1 = { # Mommy_1
						modifier = { #Children of concubines
							add = 20
							AND = {
								scope:motherless_child = {
									OR = {
										has_trait = arrogant
										has_trait = ambitious
										has_trait = bossy
										has_trait = child_of_concubine_female
										has_trait = child_of_concubine_male
										has_any_bastard_trait_trigger = yes
									}
								}
								scope:mommy_1 = {
									OR = {
										is_spouse_of = root
										any_close_family_member = {
											OR = {
												is_powerful_vassal_of = root
												is_councillor_of = root
												highest_held_title_tier >= tier_kingdom
												is_liege_or_above_of = root
											}
										}
										has_character_modifier = favored_consort_modifier
										has_character_modifier = beloved_consort_modifier
										has_character_modifier = favor_boost_modifier
									}
								}
							}
						}
						modifier = { #Spouses
							add = 20
							scope:mommy_1 = {
								is_spouse_of = root
							}
						}
						modifier = { # GC
							add = 10
							scope:mommy_1 = {
								has_court_position = grand_consort_court_position
							}
						}
						modifier = { # Primary spouse
							add = 20
							scope:mommy_1 = {
								this = root.primary_spouse
							}
						}
						modifier = { #Bullies
							add = -100
							scope:mommy_1 = {
								OR = {
									any_child = {
										OR = {
											has_relation_nemesis = scope:motherless_child
											has_relation_rival = scope:motherless_child
											has_relation_bully = scope:motherless_child
										}
									}
									OR = {
										has_relation_nemesis = scope:motherless_child
										has_relation_rival = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:mommy_1 = {
								any_child = {
									OR = {
										has_relation_friend = scope:motherless_child
										has_relation_best_friend = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:motherless_child = {
								has_relation_friend = scope:mommy_1
							}
						}
						opinion_modifier = { #Child opinion
							who = scope:motherless_child
							opinion_target = scope:mommy_1
							min = -20
							max = 20
							multiplier = 0.2
						}
						compatibility_modifier = { #Trait compatibility
							who = scope:motherless_child
							compatibility_target = scope:mommy_1
							min = -40
							max = 40
							multiplier = 2
						}
						modifier = { #Religion
							NOT = { scope:motherless_child.faith = scope:mommy_1.faith }
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.50
							}
						}
						modifier = { #Sinful traits
							scope:mommy_1 = {
								num_sinful_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.10
							}
						}
						modifier = { #Virtuous traits
							scope:mommy_1 = {
								num_virtuous_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = 0.10
							}
						}
						modifier = { #Culture
							add = 10
							scope:mommy_1.culture = scope:motherless_child.culture
						}
						modifier = { #Criminal
							scope:mommy_1 = {
								OR = {
									AND = {
										has_trait = witch
										trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = sodomite
										trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = fornicator
										trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = adulterer
										trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = incestuous
										trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = kinslayer_1
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = kinslayer_2
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = kinslayer_3
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
									AND = {
										has_trait = cannibal
										trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_1 }
									}
								}
							}
							add = -50
						}
						scope:mommy_1 = {
							save_scope_as = new_parent
						}
						scope:mommy_2 = {
							save_scope_as = non_parent_1
						}
						scope:mommy_3 = {
							save_scope_as = non_parent_2
						}
						set_mother_consort_effect = yes
					}
					1 = { # Mommy_2
						modifier = { #Children of concubines
							add = 20
							AND = {
								scope:motherless_child = {
									OR = {
										has_trait = arrogant
										has_trait = ambitious
										has_trait = bossy
										has_trait = child_of_concubine_female
										has_trait = child_of_concubine_male
										has_any_bastard_trait_trigger = yes
									}
								}
								scope:mommy_2 = {
									OR = {
										is_spouse_of = root
										any_close_family_member = {
											OR = {
												is_powerful_vassal_of = root
												is_councillor_of = root
												highest_held_title_tier >= tier_kingdom
												is_liege_or_above_of = root
											}
										}
										has_character_modifier = favored_consort_modifier
										has_character_modifier = beloved_consort_modifier
										has_character_modifier = favor_boost_modifier
									}
								}
							}
						}
						modifier = { #Spouses
							add = 20
							scope:mommy_2 = {
								is_spouse_of = root
							}
						}
						modifier = { # GC
							add = 10
							scope:mommy_2 = {
								has_court_position = grand_consort_court_position
							}
						}
						modifier = { # Primary spouse
							add = 20
							scope:mommy_2 = {
								this = root.primary_spouse
							}
						}
						modifier = { #Bullies
							add = -100
							scope:mommy_2 = {
								OR = {
									any_child = {
										OR = {
											has_relation_nemesis = scope:motherless_child
											has_relation_rival = scope:motherless_child
											has_relation_bully = scope:motherless_child
										}
									}
									OR = {
										has_relation_nemesis = scope:motherless_child
										has_relation_rival = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:mommy_2 = {
								any_child = {
									OR = {
										has_relation_friend = scope:motherless_child
										has_relation_best_friend = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:motherless_child = {
								has_relation_friend = scope:mommy_2
							}
						}
						opinion_modifier = { #Child opinion
							who = scope:motherless_child
							opinion_target = scope:mommy_2
							min = -20
							max = 20
							multiplier = 0.2
						}
						compatibility_modifier = { #Trait compatibility
							who = scope:motherless_child
							compatibility_target = scope:mommy_2
							min = -40
							max = 40
							multiplier = 2
						}
						modifier = { #Religion
							NOT = { scope:motherless_child.faith = scope:mommy_2.faith }
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.50
							}
						}
						modifier = { #Sinful traits
							scope:mommy_2 = {
								num_sinful_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.10
							}
						}
						modifier = { #Virtuous traits
							scope:mommy_2 = {
								num_virtuous_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = 0.10
							}
						}
						modifier = { #Culture
							add = 10
							scope:mommy_2.culture = scope:motherless_child.culture
						}
						modifier = { #Criminal
							scope:mommy_2 = {
								OR = {
									AND = {
										has_trait = witch
										trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = sodomite
										trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = fornicator
										trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = adulterer
										trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = incestuous
										trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = kinslayer_1
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = kinslayer_2
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = kinslayer_3
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
									AND = {
										has_trait = cannibal
										trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_2 }
									}
								}
							}
							add = -50
						}
						scope:mommy_1 = {
							save_scope_as = non_parent_1
						}
						scope:mommy_2 = {
							save_scope_as = new_parent
						}
						scope:mommy_3 = {
							save_scope_as = non_parent_2
						}
						set_mother_consort_effect = yes
					}
					1 = { # Mommy_3
						modifier = { #Children of concubines
							add = 20
							AND = {
								scope:motherless_child = {
									OR = {
										has_trait = arrogant
										has_trait = ambitious
										has_trait = bossy
										has_trait = child_of_concubine_female
										has_trait = child_of_concubine_male
										has_any_bastard_trait_trigger = yes
									}
								}
								scope:mommy_3 = {
									OR = {
										is_spouse_of = root
										any_close_family_member = {
											OR = {
												is_powerful_vassal_of = root
												is_councillor_of = root
												highest_held_title_tier >= tier_kingdom
												is_liege_or_above_of = root
											}
										}
										has_character_modifier = favored_consort_modifier
										has_character_modifier = beloved_consort_modifier
										has_character_modifier = favor_boost_modifier
									}
								}
							}
						}
						modifier = { #Spouses
							add = 20
							scope:mommy_3 = {
								is_spouse_of = root
							}
						}
						modifier = { # GC
							add = 10
							scope:mommy_3 = {
								has_court_position = grand_consort_court_position
							}
						}
						modifier = { # Primary spouse
							add = 20
							scope:mommy_3 = {
								this = root.primary_spouse
							}
						}
						modifier = { #Bullies
							add = -100
							scope:mommy_3 = {
								OR = {
									any_child = {
										OR = {
											has_relation_nemesis = scope:motherless_child
											has_relation_rival = scope:motherless_child
											has_relation_bully = scope:motherless_child
										}
									}
									OR = {
										has_relation_nemesis = scope:motherless_child
										has_relation_rival = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:mommy_3 = {
								any_child = {
									OR = {
										has_relation_friend = scope:motherless_child
										has_relation_best_friend = scope:motherless_child
									}
								}
							}
						}
						modifier = { #Friends
							add = 50
							scope:motherless_child = {
								has_relation_friend = scope:mommy_3
							}
						}
						opinion_modifier = { #Child opinion
							who = scope:motherless_child
							opinion_target = scope:mommy_3
							min = -20
							max = 20
							multiplier = 0.2
						}
						compatibility_modifier = { #Trait compatibility
							who = scope:motherless_child
							compatibility_target = scope:mommy_3
							min = -40
							max = 40
							multiplier = 2
						}
						modifier = { #Religion
							NOT = { scope:motherless_child.faith = scope:mommy_3.faith }
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.50
							}
						}
						modifier = { #Sinful traits
							scope:mommy_3 = {
								num_sinful_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = -0.10
							}
						}
						modifier = { #Virtuous traits
							scope:mommy_3 = {
								num_virtuous_traits >= 1
							}
							add = {
								value = scope:motherless_child.ai_zeal
								multiply = 0.10
							}
						}
						modifier = { #Culture
							add = 10
							scope:mommy_3.culture = scope:motherless_child.culture
						}
						modifier = { #Criminal
							scope:mommy_3 = {
								OR = {
									AND = {
										has_trait = witch
										trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = sodomite
										trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = fornicator
										trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = adulterer
										trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = incestuous
										trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = kinslayer_1
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = kinslayer_2
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = kinslayer_3
										trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = deviant
										trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
									AND = {
										has_trait = cannibal
										trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:mommy_3 }
									}
								}
							}
							add = -50
						}
						scope:mommy_1 = {
							save_scope_as = non_parent_1
						}
						scope:mommy_2 = {
							save_scope_as = non_parent_2
						}
						scope:mommy_3 = {
							save_scope_as = new_parent
						}
						set_mother_consort_effect = yes
					}
					1 = { #The child chooses their biological dead mom. They'll be better taken care of
						modifier = { #Filial
							add = 250
							scope:motherless_child = { 
								OR = {
									faith = { has_doctrine = tenet_ancestor_worship }
									culture = { has_cultural_tradition = tradition_mystical_ancestors }
								}
							}
						}
						modifier = { #Depending on their age, they might hold their parents in high regards
							add = 40
							age >= 13
						}
						modifier = {
							add = 15
							AND = {
								scope:motherless_child  = {
									is_male = yes
								}
								is_male = yes
							}
						}
						modifier = {
							add = 15
							AND = {
								scope:motherless_child  = {
									is_female = yes
								}
								is_female = yes
							}
						}
						send_interface_toast = {
							left_icon = root
							right_icon = scope:motherless_child
							title = harem_politics.0007.root.tt
							
							scope:motherless_child = {
								if = { 
									limit = {
										root = { num_of_relation_ward < 2 }
									}
									hidden_effect = {
										if = {
											limit = {
												any_relation = {
													type = guardian
													count > 0
												}
											}
											random_relation = {
												type = guardian
												save_scope_as = old_guardian
											}
											remove_relation_guardian = scope:old_guardian
										}
									}
									set_relation_guardian = root
								}
								add_opinion = {
									modifier = thankful_consort_opinion
									target = root
								}
								if = {
									limit = { 
										NOR = {
											has_relation_friend = root
											has_relation_best_friend = root
										}
									}
									set_relation_friend = { 
										reason = friend_motherless_child_ward_reason
										target = root 
									}
								}
							}
							stress_impact = {
								compassionate = minor_stress_impact_loss
								forgiving = minor_stress_impact_loss
							}
						}
						scope:motherless_child = {
							change_current_weight = 15
							add_character_modifier = {
								modifier = favored_child_modifier
								years = 3
							}
						}
					}
				}
			}
		}
		ai_chance = {
			base = 35
			modifier = {
				add = 50
				OR = {
					has_trait = compassionate
					has_trait = trusting
				}
			}
			modifier = {
				add = 40
				scope:motherless_child = {
					age >= 12
				}
			}
			modifier = {
				add = 50
				OR = {
					AND = {
						opinion = {
							target = scope:mommy_1
							value <= low_negative_opinion
						}
						opinion = {
							target = scope:mommy_2
							value <= low_negative_opinion
						}
						opinion = {
							target = scope:mommy_3
							value <= low_negative_opinion
						}
					}
					AND = {
						scope:mommy_1 = {
							OR = {
								has_character_modifier = forgotten_consort_modifier
								has_character_modifier = unfavored_consort_modifier
							}
						}
						scope:mommy_2 = {
							OR = {
								has_character_modifier = forgotten_consort_modifier
								has_character_modifier = unfavored_consort_modifier
							}
						}
						scope:mommy_3 = {
							OR = {
								has_character_modifier = forgotten_consort_modifier
								has_character_modifier = unfavored_consort_modifier
							}
						}
					}
				}
			}
		}
	}
}

################################################
##Consort asks you to give titles to relatives##
################################################
scripted_trigger harem_politics_valid_relative_trigger = {
	any_liege_or_above = {
		this = root
	}
	is_available_healthy_ai_adult = yes
	any_held_title = { count = 0 }
	NOR = {
		has_trait = ill
		has_trait = wounded
		has_character_modifier = recently_tortured
		any_consort = {
			this = root
		}
		is_child_of = root
		any_heir_title = {} # Not heir to anything
		has_hook = root
	}
	trigger_if = {
		limit = { is_female = yes }
		ROOT = { faith_dominant_gender_female_or_equal = yes }
	}
	trigger_else = { faith_dominant_gender_male_or_equal = yes }
	OR = {
		AND = {
			exists = dynasty
			NOT = {
				dynasty = root.dynasty
			}
		}
		NOT = {
			exists = dynasty
		}
	}
}

scripted_trigger harem_politics_ambitious_consort_trigger = {
	is_courtier_of = root
	OR = {
		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_lover = root
		has_relation_soulmate = root
		
		is_spouse_of = root
		has_court_position = grand_consort_court_position
		is_parent_of = root

		harem_politics_favored_consort_trigger = yes
	}
	is_demoted_consort_trigger = no
	is_physically_able_ai = yes
	is_healthy = yes
	NOR = { 
		has_character_flag = requested_favor_flag

		has_opinion_modifier = {
			target = root
			modifier = forced_me_concubine_marriage_opinion
		}
		
		has_trait = ill
		has_trait = wounded
		has_trait = shy
		has_trait = craven
		has_trait = temperate

		has_hook = root
	}
	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
	OR = { #Correct traits
		has_trait = ambitious
		has_trait = greedy
		has_trait = arrogant
	}
	trigger_if = {
		limit = {
			exists = dynasty
			exists = root.dynasty
		}
		NOT = {
			dynasty = root.dynasty
		}
	}
}

scripted_trigger harem_politics_valid_consort_0008_trigger = {
	harem_politics_ambitious_consort_trigger = yes
	OR = {
		AND = {
			any_close_or_extended_family_member = {
				NOT = {
					is_child_of = root
				}
				count = 0 
			}
			age <= 34
		}
		any_close_or_extended_family_member = {
			harem_politics_valid_relative_trigger = yes
			count >= 1
		}
	}
}

harem_politics.0008 = {
	type = character_event
	title = harem_politics.0008.t
	desc = harem_politics.0008.desc
	theme = realm
	
	left_portrait  = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:meddling_relative
		animation = personality_content
	}
	lower_center_portrait = {
		character = scope:consort_relative
	}
	
	trigger = {
		any_courtier = {
			harem_politics_valid_consort_0008_trigger = yes
		}
		OR = {
        	any_held_title = {
	        	tier = tier_barony
	        	is_capital_barony = no
	        	is_leased_out = no
				NOR = { 
					THIS = ROOT.capital_barony 
					title_province = { 
						OR = {
							has_holding_type = city_holding 
							has_holding_type = church_holding
						}
					}
				}
	        }
	        any_held_title = {
	        	count >= 4
	        	tier = tier_county
	        }
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOR = {
        	has_character_flag = had_ambitious_consort_flag
	    }
	}

	weight_multiplier = {
		base = 1
		modifier = { #Many baronies
			add = 0.1
			any_held_title = {
				tier = tier_barony
				count >= 2
			}
		}
		modifier = { #Many baronies
			add = 0.1
			any_held_title = {
				tier = tier_barony
				count >= 3
			}
		}
		modifier = { #Many baronies
			add = 0.1
			any_held_title = {
				tier = tier_barony
				count >= 4
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 5
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 6
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 7
			}
		}
		modifier = { #To make things interesting to generous characters
			add = 0.20
			has_trait = generous
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_courtier = {
			limit = {
				harem_politics_valid_consort_0008_trigger = yes
			}
			add_to_list = requester_list
		}
		
		random_in_list = {
			list = requester_list
			weight = {
				base = 10
				modifier = { #The main spouse
					this = root.primary_spouse
					add = 20
				}
				modifier = { #The Empress Dowager
					any_child = {
						this = root
					}
					add = 20
				}
				modifier = { #Grand Consort
					has_court_position = grand_consort_court_position
					add = 15
				}
				modifier = { #Spouses rank higher
					is_spouse_of = root
					add = 10
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 50
				}
				modifier = { #Lover
					has_relation_lover = root
					add = 25
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Friends
					has_relation_friend = root
					add = 10
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				modifier = { #Favored consort
					has_character_modifier = beloved_consort_modifier
					add = 25
				}
				modifier = { #Favored consort
					has_character_modifier = favor_boost_modifier
					add = 10
				}
				modifier = { #Good contacts
					any_child = {
						is_child_of = root
						count >= 3
					}
					add = 10
				}
				modifier = {
					has_trait = deceitful
					add = 15
				}
				modifier = { #Faith
					faith = root.faith
					add = 10
				}
				modifier = { #Culture
					culture = root.culture
					add = 10
				}
			}
			save_scope_as = meddling_relative
		}
		
		scope:meddling_relative = {
			if = {
				limit = {
					any_close_or_extended_family_member = {
						NOT = {
							is_child_of = root
						}
						count = 0 
					}
					age <= 34
				}
				#Create the relatives
				create_character = {
					location = root.capital_province
					template = consort_relative_template
					gender = male
					age = meddling_relative_parent_age
					save_scope_as = meddling_relative_father
				}
				create_character = {
					location = root.capital_province
					template = consort_relative_template
					gender = female
					age = meddling_relative_parent_age
					save_scope_as = meddling_relative_mother
				}
				hidden_effect = {
					random = {
						chance = 100
						random_list = {
							0 = { # The mother is the house head
								modifier = {
									ROOT = { faith_dominant_gender_female_or_equal = yes }
									add = 50
								}
								scope:meddling_relative_mother = {
									marry_matrilineal = scope:meddling_relative_father
									if = {
										limit = {
											exists = scope:meddling_relative.house
										}
										set_house = scope:meddling_relative.house
									}
									save_scope_as = consort_relative
								}
							}
							0 = { # The father is the house head
								modifier = {
									ROOT = { faith_dominant_gender_male_or_equal = yes }
									add = 50
								}
								scope:meddling_relative_father = {
									marry = scope:meddling_relative_mother
									if = {
										limit = {
											exists = scope:meddling_relative.house 
										}
										set_house = scope:meddling_relative.house
									}
									save_scope_as = consort_relative
								}
							}
						}
					}

					scope:meddling_relative = {
						set_mother = scope:meddling_relative_mother
						set_father = scope:meddling_relative_father
					}
					create_character = { #A sibling
						location = root.capital_province
						template = consort_relative_template
						gender_female_chance = {
							if = { # Higher chance for non-dominant gender
								limit = { root.faith = { has_doctrine = doctrine_gender_male_dominated } }
								add = 0
							}
							else_if = {
								limit = { root.faith = { has_doctrine = doctrine_gender_female_dominated } }
								add = 100
							}
							else = {
								add = 50
							}
						}
						age = meddling_relative_sibling_age
						save_scope_as = meddling_relative_sibling
					}
					scope:meddling_relative_sibling = {
						set_mother = scope:meddling_relative_mother
						set_father = scope:meddling_relative_father
						if = {
							limit = {
								exists = scope:meddling_relative.house
							}
							set_house = scope:meddling_relative.house
						}
					}
					if = {
						limit = {
							house ?= {
								house_head = prev
							}
						}
						house = { set_house_head = scope:consort_relative }
					}
					root = {
						add_courtier = scope:meddling_relative_sibling
						add_courtier = scope:meddling_relative_father
						add_courtier = scope:meddling_relative_mother
					}
				}
			}
			else = {
				every_close_or_extended_family_member = {
					limit = {
						harem_politics_valid_relative_trigger = yes
					}
					add_to_list = valid_relative_list
				}
				random_in_list = {
					list = valid_relative_list
					weight = {
						base = 10
						modifier = { #Siblings are priority
							any_close_family_member = { this = scope:meddling_relative }
							add = 25
						}
						modifier = { #Parents event more
							any_child = {
								this = scope:meddling_relative
							}
							add = 15
						}
						modifier = { #Same dynasty
							exists = dynasty
							exists = scope:meddling_relative.dynasty
							dynasty = scope:meddling_relative.dynasty
							add = 20
						}
						modifier = { #Same house
							exists = house
							exists = scope:meddling_relative.house
							house = scope:meddling_relative.house
							add = 15
						}
						modifier = { #House Head
							exists = scope:meddling_relative.house.house_head
							this = scope:meddling_relative.house.house_head
							add = 15
						}
						modifier = { #Opinion
							opinion = {
								target = scope:meddling_relative
								value >= low_positive_opinion
							}
							add = 20
						}
					}
					save_scope_as = consort_relative
				}
			}
		}
		
		if = { # Find a valid barony to give away
        	limit = {
        		any_held_title = {
        			tier = tier_barony
        			is_capital_barony = no
        			is_leased_out = no
        			NOR = { 
						THIS = ROOT.capital_barony 
						title_province = { 
							OR = {
								has_holding_type = city_holding 
								has_holding_type = church_holding
							}
						}
					}
        		}
        	}
        	ordered_held_title = {
	        	limit = {
	        		tier = tier_barony
	        		is_capital_barony = no
        			is_leased_out = no
        			NOR = { 
						THIS = ROOT.capital_barony 
						title_province = { 
							OR = {
								has_holding_type = city_holding 
								has_holding_type = church_holding
							}
						}
					}
	        	}
	        	order_by = {
	        		value = 0
	        		subtract = title_province.combined_building_level
	        	}
	        	save_scope_as = worst_title
	        }
        }
        else = { # Find a valid county to give away
	        ordered_held_title = {
	        	limit = {
	        		tier = tier_county
	        		NOT = { THIS = ROOT.capital_county }
	        	}
	        	order_by = {
	        		value = 0
	        		subtract = development_level
	        	}
	        	save_scope_as = worst_title
	        }
	    }
	}
	
	option = { #Give title away
        name = harem_politics.0008.a
		scope:meddling_relative = {
			calyver_favor_big_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
			add_character_flag = {
				flag = requested_favor_flag
				years = 3
			}
        }
		hidden_effect = {
			every_consort = {
				limit = {
					AND = {
						NOR = {
							this = scope:meddling_relative
							any_close_or_extended_family_member = {
								this = scope:meddling_relative
							}
							has_relation_best_friend = scope:meddling_relative
							has_relation_friend = scope:meddling_relative
							has_relation_lover = scope:meddling_relative
							has_relation_soulmate = scope:meddling_relative
						}
						harem_politics_evil_consort_trigger = yes
					}
				}
				add_opinion = {
					target = scope:meddling_relative
					modifier = envy_consort_opinion
				}
			}
			scope:consort_relative = {
				add_opinion = {
					target = scope:meddling_relative
					modifier = grateful_opinion
					opinion = 20
				}
			}
		}
		send_interface_toast = {
			left_icon = scope:consort_relative
			title = harem_politics.0008.a.tt
			ROOT = {
				create_title_and_vassal_change = {
					type = granted
					save_scope_as = change
					add_claim_on_loss = no
				}
				scope:worst_title = {
					change_title_holder = {
						holder = scope:consort_relative
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
				scope:consort_relative = {
					if = {
						limit = { scope:worst_title.tier = tier_barony }
						add_opinion = {
							target = ROOT
							modifier = received_title_barony
						}
					}
					else = {
						add_opinion = {
							target = ROOT
							modifier = received_title_county
						}
					}
					if = {
						limit = {
							NOT = {
								is_allied_to = root
							}
						}
						if = {
							limit = {
								is_close_family_of = scope:meddling_relative
							}
							create_alliance = {
								target = root
								allied_through_owner = root
								allied_through_target = scope:meddling_relative
							}
						}
						else = {
							add_truce_both_ways = {
								character = root
								years = 4
								name = TRUCE_HAREM
							}
						}
					}
				}
				if = {
					limit = {
						can_add_hook = {
							target = scope:consort_relative
							type = indebted_hook
						}
					}
					add_hook = {
						target = scope:consort_relative
						type = indebted_hook
					}
				}
			}
		}
		if = { #Stress gains unless you are over your domain limit
			limit = {
				domain_size <= domain_limit
			}
			stress_impact = {
				greedy = medium_stress_impact_gain # But, titles
				diligent = medium_stress_impact_gain # But, I like managing stuff
				arrogant = medium_stress_impact_gain # But, my titles
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.5
   				ai_greed = -1
   			}
            modifier = { # Weight up for family members.
            	add = 15
            	scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            }
            modifier = { # Weight up for dynasty members.
            	add = 15
				exists = scope:consort_relative.dynasty
            	scope:consort_relative.dynasty = ROOT.dynasty
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= low_positive_opinion
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= 50
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 5
            	opinion = {
            		target = scope:consort_relative
            		value >= 50
            	}
            }
			modifier = { #Fertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count >= 3
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_close_or_extended_family_member = {
						OR = {
							this = root.primary_spouse
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				exists = root.primary_spouse
				scope:meddling_relative = {
					this = root.primary_spouse
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = 5
			}

			modifier = { #Martial
				scope:consort_relative = {
					martial >= very_high_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship >= very_high_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial >= high_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship >= high_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial >= decent_skill_rating
				}
				add = 5
			}
			modifier = { #stewardship
				scope:consort_relative = {
					stewardship >= decent_skill_rating
				}
				add = 5
			}

            modifier = {	#Weight down for stress.
				add = -25
				has_trait = greedy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = diligent
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = humble
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = lazy
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favor_boost_modifier
				}
				add = 5
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root
					}
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root.primary_heir
					}
				}
				add = 10
			}
        }
    }

	option = { # Compromise - give them gold
        name = harem_politics.0031.b
		trigger = {
			gold >= minor_gold_value
		}
		show_as_unavailable = { NOT = { gold >= minor_gold_value } }
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= minor_gold_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		save_scope_value_as = {
			name = gold_to_pay
			value = minor_gold_value
		}
		pay_short_term_gold = {
			target = scope:consort_relative
			gold = scope:gold_to_pay
		}
		scope:consort_relative = {
			add_opinion = {
				target = scope:meddling_relative
				modifier = grateful_opinion
				opinion = 10
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
        scope:meddling_relative = {
			calyver_favor_moderate_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
			add_character_flag = {
				flag = requested_favor_flag
				years = 2
			}
        }
		hidden_effect = {
			every_consort = {
				limit = {
					AND = {
						NOR = {
							this = scope:meddling_relative
							any_close_or_extended_family_member = {
								this = scope:meddling_relative
							}
							has_relation_best_friend = scope:meddling_relative
							has_relation_friend = scope:meddling_relative
							has_relation_lover = scope:meddling_relative
							has_relation_soulmate = scope:meddling_relative
						}
						harem_politics_evil_consort_trigger = yes
					}
				}
				add_opinion = {
					target = scope:meddling_relative
					modifier = envy_consort_opinion
					opinion = -5
				}
			}
		}
        stress_impact = {
			greedy = medium_stress_impact_gain # But, titles
			arrogant = medium_stress_impact_gain # But, my titles
			generous = minor_stress_impact_loss
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.75
   				ai_greed = -0.5
   			}
			modifier = {
				gold <= medium_gold_value
				add = -15
			}
            modifier = { # Weight up for family members.
            	add = 15
            	scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= low_positive_opinion
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= 50
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 5
            	opinion = {
            		target = scope:consort_relative
            		value >= 50
            	}
            }
			modifier = { #Fertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count >= 3
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_close_or_extended_family_member = {
						OR = {
							this = root.primary_spouse
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				exists = root.primary_spouse
				scope:meddling_relative = {
					this = root.primary_spouse
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = 5
			}

            modifier = {	#Weight down for stress.
				add = -15
				has_trait = greedy
			}
			modifier = {	#Weight down for stress.
				add = 20
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -15
				has_trait = arrogant
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favor_boost_modifier
				}
				add = 5
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root
					}
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root.primary_heir
					}
				}
				add = 15
			}
        }
    }
	
	option = { # You get nothing!
        name = harem_politics.0008.b
        scope:meddling_relative = {
			calyver_favor_minor_loss_effect = yes
        	add_opinion = {
        		target = ROOT
        		modifier = annoyed_opinion
        		opinion = -15
        	}
			add_character_flag = {
				flag = requested_favor_flag
				years = 5
			}
        }
        stress_impact = {
        	generous = medium_stress_impact_gain # But I have so much to give
        	lazy = medium_stress_impact_gain # I would rather have someone else do it
        	humble = medium_stress_impact_gain # Who am I to deny them?
        }
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_boldness = 1
   				ai_greed = 1
				ai_honor = 0.1
   			}
            modifier = { # Weight up for NO family members.
            	add = 15
            	NOT = {
            		scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            	}
            }
            modifier = { # Weight up for NO dynasty members.
            	factor = 2
            	NOT = {
            		scope:consort_relative.dynasty = ROOT.dynasty
            	}
            }
           modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value <= 0
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 20
            	opinion = {
            		target = scope:meddling_relative
            		value <= 20
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:consort_relative
            		value <= 20
            	}
            }
			modifier = { #Non-influential consort
				scope:meddling_relative = {
					is_concubine_of = root
				}
				add = 20
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial <= mediocre_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship <= mediocre_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial <= low_skill_rating
				}
				add = 10
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship <= low_skill_rating
				}
				add = 10
			}
			modifier = {	#Weight down for stress.
				scope:consort_relative = {
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
					}
				}
				add = 20
			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = lazy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = humble
			}
			modifier = { #Infertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count = 0
					}
				}
				add = 10
			}
        }
    }
	after = {
		add_character_flag = {
			flag = had_ambitious_consort_flag
			years = 5
		}
	}
}

########################
##Meeting Consort Ling##
########################

## Creation effect
scripted_effect create_yanwan_effect = {
	# Choose the reference location
	hp_select_concubine_location_effect = yes
	hp_character_creation_effect = {
		CHARACTER = yanwan
	}
}

## Make them a concubine
scripted_effect base_make_concubine_harem_politics_events_effect = {
	hidden_effect = {
		add_courtier = $CONSORT$
		run_interaction = {
			interaction = make_concubine_interaction
			actor = scope:harem_liege
			recipient = $CONSORT$
			execute_threshold = accept
		}
	}
	show_as_tooltip = {
		make_concubine = $CONSORT$
	}
}

scripted_effect take_special_concubine_event_effect = {
	base_make_concubine_harem_politics_events_effect = {
		CONSORT = $RECIPIENT$
	}
	$RECIPIENT$ = {
		if = {
			limit = {
				root = {
					any_consort = {
						is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
						has_variable = favor
						count >= 3
					}
				}
			}
			set_variable = {
				name = favor
				value = initial_favor_valuation
			}
			calyver_favor_moderate_gain_effect = yes
		}
		add_opinion = {
			target = root
			modifier = grateful_opinion
			opinion = 10
		}
		add_character_flag = flag_$FLAG$
	}
}
scripted_effect take_special_concubine_event_with_other_consort_effect = {
	take_special_concubine_event_effect = {
		RECIPIENT = $RECIPIENT$
		FLAG = $FLAG$
	}
	$CURRENT_CONSORT$ = {
		calyver_favor_minor_loss_effect = yes
		add_opinion = {
			target = root
			modifier = disappointed_opinion
			opinion = -15
		}
		add_opinion = {
			target = $RECIPIENT$
			modifier = hatred_spouse_opinion
		}
		set_relation_potential_rival = $RECIPIENT$
	}
}

##Through Consort Chun##

scripted_trigger chun_fei_trigger = {
	OR = {
		is_married = yes
		is_grand_consort_trigger = yes
	}
	any_child = {
		is_physically_able_ai = yes
		is_adult = no
		is_courtier_of = root
		is_child_of = root
		age >= 9
		OR = {
			AND = {
				is_travelling = yes
				current_travel_plan = {
					travel_plan_owner = root
				}
			}
			AND = {
				is_travelling = no
				root = {
					is_travelling = no
				}
			}
		}
		is_hostage = no
		count >= 1
	}
	is_demoted_consort_trigger = no
	is_courtier_of = root
	is_physically_able_ai_adult = yes
	harem_politics_forgotten_consort_trigger = no
	NOR = {
		has_trait = ill
		has_trait = wounded

	}
	harem_politics_punished_consort_trigger = no
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0009 = {
	type = character_event
	title = harem_politics.0009.t
	desc = harem_politics.0009.desc
	theme = family
	
	left_portrait  = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:yanwan
		animation = flirtation
	}
	lower_center_portrait = {
		character = scope:chun_fei
	}
	
	trigger = {
		any_consort = {
			chun_fei_trigger = yes
		}
		NOR = {
        	any_consort = {
	        	has_character_flag = flag_yanwan
	        }
			has_character_flag = met_yanwan_chun_fei
			has_character_modifier = mourner_modifier
	    }
		allowed_more_concubines = yes
		is_available_healthy_adult = yes
		is_available_at_peace_adult = yes
		highest_held_title_tier >= tier_kingdom
		trigger_if = {
			limit = {
				has_ep1_dlc_trigger = yes
			}
			trigger_if = {
				limit = {
					NOT = {
						government_has_flag = government_is_tribal
					}
				}
				has_royal_court = yes
				amenity_level = {
					type = court_servants
					value >= 3
				}
			}
			trigger_else = {
				government_has_flag = government_is_tribal
			}
		}
		trigger_else = {
			has_ep1_dlc_trigger = no
		}
		harem_politics_valid_event_county_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			number_of_concubines < number_of_desired_concubines
			add = 0.1
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.10
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = { #Find Consort Chun
			limit = {
				chun_fei_trigger = yes
			}
			add_to_list = chun_fei_list
		}
		
		random_in_list = {
			list = chun_fei_list
			weight = {
				base = 10
				modifier = {
					any_child = {
						is_child_of = root
						is_hostage = no
						count >= 2
					}
					add = 20
				}
				modifier = {
					harem_politics_evil_consort_trigger = yes
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
			}
			save_scope_as = chun_fei
		}
		
		scope:chun_fei = {
			random_child = {
				limit = {
					AND = {
						is_physically_able_ai = yes
						is_adult = no
						is_courtier_of = root
						is_child_of = root
						age >= 9
						OR = {
							AND = {
								is_travelling = yes
								current_travel_plan = {
									travel_plan_owner = root
								}
							}
							AND = {
								is_travelling = no
								root = {
									is_travelling = no
								}
							}
						}
						is_hostage = no
					}
				}
				save_scope_as = yonghuang
			}
		}
		#Create Yanwan
		create_yanwan_effect = yes
	}
	
	option = { #Take Yanwan as a concubine
        name = harem_politics.0009.a
		trigger = {
			allowed_more_concubines = yes
		}
		take_special_concubine_event_with_other_consort_effect = {
			RECIPIENT = scope:yanwan
			CURRENT_CONSORT = scope:chun_fei
			FLAG = yanwan
		}
		hidden_effect = {
			every_consort = { #Consorts think Chun shoved a concubine to gain favor
				limit = {
					AND = {
						NOR = {
							this = scope:yanwan
							this = scope:chun_fei
							has_relation_best_friend = scope:chun_fei
							has_relation_friend = scope:chun_fei
							has_relation_lover = scope:chun_fei
							has_relation_soulmate = scope:chun_fei
						}
						harem_politics_evil_consort_trigger = yes
						OR = {
							hp_accepts_concubinage = yes
							hp_accepts_polygamy = yes
						}
					}
				}
				add_opinion = {
					target = scope:chun_fei
					modifier = hatred_spouse_opinion
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain 
			arrogant = minor_stress_impact_gain 
			paranoid = minor_stress_impact_gain 
			shy = minor_stress_impact_gain 
		}
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_rationality = -0.1
				ai_honor = -0.1
				ai_boldness = 0.1
				ai_sociability = 0.15
   			}
			opinion_modifier = {
				opinion_target = scope:yanwan
				min = -30
				max = 30
				multiplier = 1
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:yanwan
				min = -20
				max = 20
				multiplier = 2
			}

			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

            modifier = {	#Weight up for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {
				scope:chun_fei = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:yanwan } }
				factor = 0
			}
        }
    }
	
	option = { # Consort Chun is a good parent
        name = harem_politics.0009.b
        scope:chun_fei = {
			calyver_favor_minor_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
			if = {
				limit = {
					NOR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
        }
		hidden_effect = {
			scope:yanwan = {
				death = {
					death_reason = death_vanished
				}
			}
		}
        stress_impact = {
        	lustful = minor_stress_impact_gain
        }
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_rationality = 0.1
				ai_honor = 0.15
				ai_boldness = -0.1
				ai_sociability = -0.3
			}
			opinion_modifier = {
				opinion_target = scope:chun_fei
				min = -25
				max = 25
				multiplier = 1
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:chun_fei
				min = -30
				max = 30
				multiplier = 2
			}

            modifier = {	#Weight up for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = shy
			}
			modifier = {
				scope:chun_fei = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:chun_fei = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:chun_fei = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
        }
    }
	after = {
		add_character_flag = met_yanwan_chun_fei
	}
}

##Through Consort Jia##

scripted_trigger jia_fei_trigger = {
	OR = {
		is_married = yes
		is_grand_consort_trigger = yes
	}
	is_demoted_consort_trigger = no
	harem_politics_evil_consort_trigger = yes
	is_courtier_of = root
	is_physically_able_ai_adult = yes
	harem_politics_forgotten_consort_trigger = no
	NOR = {
		has_trait = ill
		has_trait = wounded
		has_trait = temperate
		has_trait = calm
	}
	harem_politics_punished_consort_trigger = no
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0010 = {
	type = character_event
	title = harem_politics.0010.t
	desc = harem_politics.0010.desc
	theme = family
	override_background = {
		reference = garden
	}
	
	left_portrait  = {
		character = root
		animation = disapproval
	}
	right_portrait = {
		character = scope:jia_fei
		animation = shame
	}
	lower_center_portrait = {
		character = scope:yanwan
	}
	
	trigger = {
		any_consort = {
			jia_fei_trigger = yes
		}
		NOR = {
        	any_consort = {
	        	has_character_flag = flag_yanwan
	        }
			has_character_flag = met_yanwan_jia_fei
			has_character_modifier = mourner_modifier
	    }
		allowed_more_concubines = yes
		is_available_healthy_adult = yes
		is_available_at_peace_adult = yes
		highest_held_title_tier >= tier_kingdom
		trigger_if = {
			limit = {
				has_ep1_dlc_trigger = yes
			}
			trigger_if = {
				limit = {
					NOT = {
						government_has_flag = government_is_tribal
					}
				}
				has_royal_court = yes
				amenity_level = {
					type = court_servants
					value >= 3
				}
			}
			trigger_else = {
				government_has_flag = government_is_tribal
			}
		}
		trigger_else = {
			has_ep1_dlc_trigger = no
		}
		harem_politics_valid_event_county_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			number_of_concubines < number_of_desired_concubines
			add = 0.1
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.10
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = { #Find Consort Jia
			limit = {
				jia_fei_trigger = yes
			}
			add_to_list = jia_fei_list
		}
		
		random_in_list = {
			list = jia_fei_list
			weight = {
				base = 10
				modifier = {
					any_child = {
						is_child_of = root
						count >= 2
					}
					add = 20
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
			}
			save_scope_as = jia_fei
		}

		#Create Yanwan
		create_yanwan_effect = yes
		hidden_effect = {
			scope:yanwan = {
				add_opinion = {
					target = scope:jia_fei
					modifier = cruelty_opinion
					opinion = -20
				}
			}
		}
	}
	
	option = { #Take Yanwan as a concubine
        name = harem_politics.0010.a
		trigger = {
			allowed_more_concubines = yes
		}

		take_special_concubine_event_with_other_consort_effect = {
			RECIPIENT = scope:yanwan
			CURRENT_CONSORT = scope:jia_fei
			FLAG = yanwan
		}
		scope:jia_fei = {
			add_character_flag = {
				flag = flag_scolded_consort
				years = 1
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain 
			arrogant = minor_stress_impact_gain 
			paranoid = minor_stress_impact_gain 
			shy = minor_stress_impact_gain 
		}
		ai_chance = {
            base = 50
            ai_value_modifier = {
   				ai_rationality = -0.1
				ai_honor = -0.1
				ai_boldness = 0.1
				ai_sociability = 0.15
   			}
			opinion_modifier = {
				opinion_target = scope:yanwan
				min = -30
				max = 30
				multiplier = 1
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:yanwan
				min = -20
				max = 20
				multiplier = 2
			}

			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

            modifier = {	#Weight up for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {
				scope:jia_fei = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:yanwan } }
				factor = 0
			}
        }
    }
	
	option = { #Reprimand Jia
        name = harem_politics.0010.b
		scope:jia_fei = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
			add_character_flag = {
				flag = flag_scolded_consort
				years = 1
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			lustful = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
        ai_chance = {
            base = 50
            ai_value_modifier = {
   				ai_rationality = 0.1
				ai_honor = 0.1
				ai_sociability = 0.3
				ai_compassion = -0.3
   			}
			opinion_modifier = {
				opinion_target = scope:jia_fei
				min = -30
				max = 30
				multiplier = -1
			}

            modifier = {	#Weight down for stress.
				add = -25
				has_trait = forgiving
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = compassionate
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {
				add = 10
				has_trait = temperate
			}
        }
    }
	
	option = { # Consort Jia is within her rights
        name = harem_politics.0010.c
		scope:jia_fei = {
			calyver_favor_minor_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
			if = {
				limit = {
					NOR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
		}
        stress_impact = {
        	lustful = minor_stress_impact_gain
        }
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_rationality = 0.1
				ai_honor = 0.15
				ai_boldness = -0.1
				ai_sociability = -0.3
			}
			opinion_modifier = {
				opinion_target = scope:jia_fei
				min = -25
				max = 25
				multiplier = 1
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:jia_fei
				min = -30
				max = 30
				multiplier = 2
			}

            modifier = {	#Weight up for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = shy
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = compassionate
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = forgiving
			}
			modifier = {
				scope:jia_fei = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:jia_fei = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:jia_fei = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
        }
    }
	after = {
		add_character_flag = met_yanwan_jia_fei
		hidden_effect = {
			if = {
				limit = {
					scope:yanwan = {
						NOT = {
							is_consort_of = root
						}
					}
				}
				scope:yanwan = {
					death = {
						death_reason = death_vanished
					}
				}
			}
		}
	}
}

##############################
##Choosing a night companion##
##############################

scripted_trigger valid_consort_trigger = {
	is_courtier_of = root
	is_physically_able_ai_adult = yes
	harem_politics_punished_consort_trigger = no
	NOR = {
		has_trait = pregnant
		has_trait = ill
		has_trait = wounded
		has_trait = eunuch
		has_trait = celibate
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_effect rejected_consort_effect = {
	if = {
		limit = {
			opinion = {
				target = scope:chosen_consort
				value <= 15
			}
			opinion = {
				target = root
				value >= -15
			}
			harem_politics_evil_consort_trigger = yes
			OR = {
				hp_accepts_concubinage = yes
				hp_accepts_polygamy = yes
			}
			NOT = {
				has_opinion_modifier = {
					modifier = forced_me_concubine_marriage_opinion
					target = root
				}
			}
		}				
		add_opinion = {
			target = scope:chosen_consort
			modifier = jealousy_opinion
			opinion = -5
		}
		if = {
			limit = {
				can_set_relation_potential_rival_trigger = { CHARACTER = scope:chosen_consort }
			}
			set_relation_potential_rival = scope:chosen_consort
		}
	}
}

scripted_effect chosen_consort_effect = {
	had_sex_with_effect = {
		CHARACTER = scope:chosen_consort
		PREGNANCY_CHANCE = pregnancy_chance
	}
	scope:chosen_consort = {
		random_list = {
			25 = { #Progress towards lovers - root loved the consort
				simple_attraction_modifier = {
					WHO = scope:chosen_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = root
					min = -100
					max = 100
					multiplier = 1
				}
				opinion_modifier = {
					who = root
					opinion_target = scope:chosen_consort
					min = -100
					max = 100
					multiplier = 1
				}
				modifier = {
					has_trait = beauty_good_1
					add = 5
				}
				modifier = {
					has_trait = beauty_good_2
					add = 10
				}
				modifier = {
					has_trait = beauty_good_3
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 5
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 10
				}
				modifier = {
					OR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
					add = 5
				}
				modifier = {
					NOT = { root = { is_attracted_to_gender_of = scope:chosen_consort } }
					factor = 0
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = root }
					factor = 0.7
				}
				if = {
					limit = {
						NOR = {
							has_relation_lover = root
							has_relation_soulmate = root
							has_relation_potential_lover = root
						}
					}
					set_relation_potential_lover = root
				}
				add_opinion = {
					target = root
					modifier = romance_opinion
					opinion = 10
				}
				calyver_favor_medium_gain_effect = yes
			}
			50 = { #Progress towards lovers - root liked the consort
				simple_attraction_modifier = {
					WHO = scope:chosen_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = root
					opinion_target = scope:chosen_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					has_trait = beauty_good_1
					add = 5
				}
				modifier = {
					has_trait = beauty_good_2
					add = 10
				}
				modifier = {
					has_trait = beauty_good_3
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 5
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 10
				}
				modifier = {
					OR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
					add = 5
				}
				modifier = {
					NOT = { root = { is_attracted_to_gender_of = scope:chosen_consort } }
					factor = 0
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = root }
					factor = 0.7
				}
				add_opinion = {
					target = root
					modifier = romance_opinion
					opinion = 5
				}
				calyver_favor_minor_gain_effect = yes
			}
			50 = { #Nothing	
			}
		}
	}
	if = {
		limit = {
			NOT = {
				is_attracted_to_gender_of = scope:chosen_consort
			}
		}
		add_stress = minor_stress_impact_gain
	}
	stress_impact = {
		chaste = minor_stress_impact_gain
		shy = minor_stress_impact_gain
	}
	hidden_effect = {
		scope:rejected_1 = {
			rejected_consort_effect = yes
		}
		scope:rejected_2 = {
			rejected_consort_effect = yes
		}
		if = {
			limit = {
				exists = scope:rejected_3
			}
			scope:rejected_3 = {
				rejected_consort_effect = yes
			}
		}
	}
}

scripted_effect deviant_consort_effect = {
	had_sex_with_effect = {
		CHARACTER = root
		PREGNANCY_CHANCE = pregnancy_chance
	}
	random_list = {
		50 = { #Progress towards lovers
			simple_attraction_modifier = {
				WHO = prev
				TARGET = root
				MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = root
				min = -50
				max = 50
				multiplier = 0.5
			}
			modifier = {
				has_trait = lustful
				add = 50
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = root }
				factor = 0.7
			}
			if = {
				limit = {
					NOR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 5
			}
			add_trait = deviant
			calyver_favor_minor_gain_effect = yes
		}
		50 = { #Disgust
			modifier = {
				has_trait = temperate
				add = 20
			}
			modifier = {
				has_trait = zealous
				add = 10
			}
			modifier = {
				has_trait = craven
				add = 10
			}
			modifier = {
				has_trait = chaste
				add = 25
			}
			modifier = {
				has_trait = shy
				add = 10
			}
			add_opinion = {
				target = root
				modifier = disgusted_opinion
				opinion = -25
			}
		}
		25 = { #Nothing
			modifier = {
				has_trait = brave
				add = 20
			}
			modifier = {
				has_trait = cynical
				add = 10
			}
		}
	}
}

harem_politics.0011 = {
	type = character_event
	title = harem_politics.0011.t
	desc = {
		desc = harem_politics.0011.start.desc
		first_valid = {
			triggered_desc = { #Any new consort?
				trigger = {
					OR = {
						scope:new_consort_1 = {
							has_character_flag = flag_new_consort
						}
						scope:new_consort_2 = {
							has_character_flag = flag_new_consort
						}
						scope:new_consort_3 = {
							has_character_flag = flag_new_consort
						}
						AND = {
							exists = scope:old_consort
							scope:old_consort = {
								has_character_flag = flag_new_consort
							}
						}
					}
				}
				desc = harem_politics.0011.new_consort.desc
			}
			triggered_desc = {
				desc = harem_politics.0011.generic.desc
			}
		}
		desc = harem_politics.0011.end.desc
	}
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:new_consort_1
		animation = flirtation
	}
	lower_left_portrait = {
		character = scope:new_consort_2
	}
	lower_center_portrait = {
		trigger = {
			exists = scope:old_consort
		}
		character = scope:old_consort
	}
	lower_right_portrait = {
		character = scope:new_consort_3
	}
	
	trigger = {
		any_consort = {
			valid_consort_trigger = yes
			count >= 3
		}
		NOR = {
			has_character_flag = chosen_night_companion
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.2
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			add = -0.5
			has_trait = chaste
		}
		modifier = {
			add = 0.2
			has_trait = lustful
		}
		modifier = {
			add = 0.2
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.4
			age >= 45
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				valid_consort_trigger = yes
			}
			add_to_list = night_companions
		}
		
		random_in_list = {
			list = night_companions
			weight = {
				base = 10
				modifier = {
					exists = root.primary_spouse
					this = root.primary_spouse
					add = 10
				}
				modifier = {
					has_court_position = grand_consort_court_position
					add = 5
				}
				modifier = {
					NOR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = 50
				}
				modifier = {
					has_character_flag = flag_new_consort
					add = 30
				}
				modifier = {
					is_lowborn = no
					add = 5
				}
				modifier = {
					add = 10
					age <= 40
				}
				modifier = {
					is_married = yes
					add = 15
				}
				modifier = {
					NOR = {
						has_trait = one_eyed
						has_trait = scarred
						has_trait = one_legged
						has_trait = disfigured
						has_trait = scaly
						has_trait = albino
						has_trait = dwarf
						has_trait = hunchbacked
						has_trait = maimed
						has_trait = spindly
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
						has_trait = giant
					}
					add = 50
				}
				modifier = {
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 20
				}
				modifier = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = {
					has_trait = beauty_good_1
					add = 10
				}
				modifier = {
					has_trait = beauty_good_2
					add = 15
				}
				modifier = {
					has_trait = beauty_good_3
					add = 20
				}
				modifier = {
					has_character_modifier = favor_boost_modifier
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
			}
			save_scope_as = new_consort_1
		}
		random_in_list = {
			list = night_companions
			limit = {
				NOT = {
					this = scope:new_consort_1
				}
			}
			weight = {
				base = 10
				modifier = {
					exists = root.primary_spouse
					this = root.primary_spouse
					add = 10
				}
				modifier = {
					has_court_position = grand_consort_court_position
					add = 5
				}
				modifier = {
					NOR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = 50
				}
				modifier = {
					has_character_flag = flag_new_consort
					add = 30
				}
				modifier = {
					is_lowborn = no
					add = 5
				}
				modifier = {
					add = 10
					age <= 40
				}
				modifier = {
					is_married = yes
					add = 15
				}
				modifier = {
					NOR = {
						has_trait = one_eyed
						has_trait = scarred
						has_trait = one_legged
						has_trait = disfigured
						has_trait = scaly
						has_trait = albino
						has_trait = dwarf
						has_trait = hunchbacked
						has_trait = maimed
						has_trait = spindly
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
						has_trait = giant
					}
					add = 50
				}
				modifier = {
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 20
				}
				modifier = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = {
					has_trait = beauty_good_1
					add = 10
				}
				modifier = {
					has_trait = beauty_good_2
					add = 15
				}
				modifier = {
					has_trait = beauty_good_3
					add = 20
				}
				modifier = {
					has_character_modifier = favor_boost_modifier
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
			}
			save_scope_as = new_consort_2
		}
		random_in_list = {
			list = night_companions
			limit = {
				NOR = {
					this = scope:new_consort_1
					this = scope:new_consort_2
				}
			}
			weight = {
				base = 10
				modifier = {
					exists = root.primary_spouse
					this = root.primary_spouse
					add = 10
				}
				modifier = {
					has_court_position = grand_consort_court_position
					add = 5
				}
				modifier = {
					NOR = {
						has_character_modifier = demoted_primary_spouse_modifier
						has_character_modifier = demoted_spouse_modifier
					}
					add = 50
				}
				modifier = {
					has_character_flag = flag_new_consort
					add = 30
				}
				modifier = {
					is_lowborn = no
					add = 5
				}
				modifier = {
					add = 10
					age <= 40
				}
				modifier = {
					is_married = yes
					add = 15
				}
				modifier = {
					NOR = {
						has_trait = one_eyed
						has_trait = scarred
						has_trait = one_legged
						has_trait = disfigured
						has_trait = scaly
						has_trait = albino
						has_trait = dwarf
						has_trait = hunchbacked
						has_trait = maimed
						has_trait = spindly
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
						has_trait = giant
					}
					add = 50
				}
				modifier = {
					any_close_family_member = {
						is_vassal_of = root
					}
					add = 20
				}
				modifier = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
					}
					add = 20
				}
				modifier = {
					has_trait = beauty_good_1
					add = 10
				}
				modifier = {
					has_trait = beauty_good_2
					add = 15
				}
				modifier = {
					has_trait = beauty_good_3
					add = 20
				}
				modifier = {
					has_character_modifier = favor_boost_modifier
					add = 15
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
			}
			save_scope_as = new_consort_3
		}
		if = {
			limit = {
				any_consort = {
					AND = {
						valid_consort_trigger = yes
						NOR = {
							this = scope:new_consort_1
							this = scope:new_consort_2
							this = scope:new_consort_3
						}
					}
				}
			}
			random_consort = {
				limit = {
					AND = {
						valid_consort_trigger = yes
						NOR = {
							this = scope:new_consort_1
							this = scope:new_consort_2
							this = scope:new_consort_3
						}
					}
				}
				weight = {
					base = 10
					modifier = {
						exists = root.primary_spouse
						this = root.primary_spouse
						add = 10
					}
					modifier = {
						has_court_position = grand_consort_court_position
						add = 5
					}
					modifier = {
						NOR = {
							has_character_modifier = demoted_primary_spouse_modifier
							has_character_modifier = demoted_spouse_modifier
						}
						add = 50
					}
					modifier = {
						has_character_flag = flag_new_consort
						add = 30
					}
					modifier = {
						is_lowborn = no
						add = 5
					}
					modifier = {
						add = 10
						age <= 40
					}
					modifier = {
						is_married = yes
						add = 15
					}
					modifier = {
						NOR = {
							has_trait = one_eyed
							has_trait = scarred
							has_trait = one_legged
							has_trait = disfigured
							has_trait = scaly
							has_trait = albino
							has_trait = dwarf
							has_trait = hunchbacked
							has_trait = maimed
							has_trait = spindly
							has_trait = beauty_bad_1
							has_trait = beauty_bad_2
							has_trait = beauty_bad_3
							has_trait = giant
						}
						add = 50
					}
					modifier = {
						any_close_family_member = {
							is_vassal_of = root
						}
						add = 20
					}
					modifier = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								is_liege_or_above_of = root
							}
						}
						add = 20
					}
					modifier = {
						has_trait = beauty_good_1
						add = 10
					}
					modifier = {
						has_trait = beauty_good_2
						add = 15
					}
					modifier = {
						has_trait = beauty_good_3
						add = 20
					}
					modifier = {
						has_character_modifier = favor_boost_modifier
						add = 15
					}
					modifier = {
						has_character_modifier = favored_consort_modifier
						add = 10
					}
					modifier = {
						has_character_modifier = beloved_consort_modifier
						add = 20
					}
				}
				save_scope_as = old_consort
			}
		}
	}
	
	option = { # Lay with first consort
        name = harem_politics.0011.a
		scope:new_consort_1 = {
			save_scope_as = chosen_consort
		}
		scope:new_consort_2 = {
			save_scope_as = rejected_1
		}
		scope:new_consort_3 = {
			save_scope_as = rejected_2
		}
		if = {
			limit = {
				exists = scope:old_consort
			}
			scope:old_consort = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:new_consort_1
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:new_consort_1
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}
			modifier = {
            	add = 10
            	scope:new_consort_1 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_1 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_1 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_1 = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_1 = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 5
            	scope:new_consort_1 = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:new_consort_1 = {
            		fertility >= medium_fertility
            	}
            }
			modifier = {
            	add = -10
            	scope:new_consort_1 = {
            		age >= 30
            	}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:new_consort_1
					has_relation_soulmate = scope:new_consort_1
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:new_consort_1
					has_relation_friend = scope:new_consort_1
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:new_consort_1
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { # Lay with second consort
        name = harem_politics.0011.b
		scope:new_consort_1 = {
			save_scope_as = rejected_1
		}
		scope:new_consort_2 = {
			save_scope_as = chosen_consort
		}
		scope:new_consort_3 = {
			save_scope_as = rejected_2
		}
		if = {
			limit = {
				exists = scope:old_consort
			}
			scope:old_consort = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:new_consort_2
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:new_consort_2
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}
			modifier = {
            	add = 10
            	scope:new_consort_2 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_2 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_2 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_2 = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_2 = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 5
            	scope:new_consort_2 = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:new_consort_2 = {
            		fertility >= medium_fertility
            	}
            }
			modifier = {
            	add = -10
            	scope:new_consort_2 = {
            		age >= 30
            	}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:new_consort_2
					has_relation_soulmate = scope:new_consort_2
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:new_consort_2
					has_relation_friend = scope:new_consort_2
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:new_consort_2
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { # Lay with third consort
        name = harem_politics.0011.c
		scope:new_consort_1 = {
			save_scope_as = rejected_1
		}
		scope:new_consort_2 = {
			save_scope_as = rejected_2
		}
		scope:new_consort_3 = {
			save_scope_as = chosen_consort
		}
		if = {
			limit = {
				exists = scope:old_consort
			}
			scope:old_consort = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:new_consort_3
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:new_consort_3
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}
			modifier = {
            	add = 10
            	scope:new_consort_3 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_3 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_3 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:new_consort_3 = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = 15
            	scope:new_consort_3 = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 5
            	scope:new_consort_3 = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:new_consort_3 = {
            		fertility >= medium_fertility
            	}
            }
			modifier = {
            	add = -10
            	scope:new_consort_3 = {
            		age >= 30
            	}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:new_consort_3
					has_relation_soulmate = scope:new_consort_3
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:new_consort_3
					has_relation_friend = scope:new_consort_3
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:new_consort_3
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
        }
    }

	option = { # Lay with fourth consort
        name = harem_politics.0011.d
		trigger = {
			exists = scope:old_consort
		}
		scope:new_consort_1 = {
			save_scope_as = rejected_1
		}
		scope:new_consort_2 = {
			save_scope_as = rejected_2
		}
		scope:new_consort_3 = {
			save_scope_as = rejected_3
		}
		scope:old_consort = {
			save_scope_as = chosen_consort
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:old_consort
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:old_consort
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}
			modifier = {
            	add = 10
            	scope:old_consort = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:old_consort = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:old_consort = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:old_consort = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = 15
            	scope:old_consort = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 5
            	scope:old_consort = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:old_consort = {
            		fertility >= medium_fertility
            	}
            }
			modifier = {
            	add = -10
            	scope:old_consort = {
            		age >= 30
            	}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:old_consort
					has_relation_soulmate = scope:old_consort
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:old_consort
					has_relation_friend = scope:old_consort
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:old_consort
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { # Lay with all of them!
		name = harem_politics.0011.e
		flavor = harem_politics.0011.e_tt
		trait = deviant
		trigger = {
			has_trait = deviant
		}
		
		hidden_effect = {
			scope:new_consort_1 = {
				deviant_consort_effect = yes
			}
			scope:new_consort_2 = {
				deviant_consort_effect = yes
			}
			scope:new_consort_3 = {
				deviant_consort_effect = yes
			}
			if = {
				limit = {
					exists = scope:old_consort
				}
				scope:old_consort = {
					deviant_consort_effect = yes
				}
			}
		}
		stress_impact = {
			deviant = miniscule_stress_impact_loss
			rakish = minor_stress_impact_loss
			chaste = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			temperate = minor_stress_impact_gain
		}
		ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
				ai_boldness = 0.35
				ai_zeal = -0.20
   			}
            modifier = {	#Weight down for stress.
				add = 25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 50
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = temperate
			}
			modifier = {
				add = 45
				any_child = {
					count = 0
				}
			}
        }
	}
	
	option = { # I'd rather stay in bed
        name = harem_politics.0011.f
		random_list = {
			50 = {
				modifier = { #Traits
					add = 10
					has_trait = lazy
				}
				modifier = { #Traits
					add = 10
					has_trait = trusting
				}
				modifier = { #Traits
					add = 5
					has_trait = shy
				}
				modifier = { #Traits
					add = 10
					has_trait = calm
				}
				modifier = { #Energy
					add = 10
					ai_energy <= low_positive_energy
				}
				modifier = { #Stress
					add = 10
					stress >= normal_baseline_stress
				}
				add_character_modifier = {
					modifier = well_rested_modifier
					years = 1
				}
			}
			50 = { #Nothing
				modifier = { #Traits
					add = 10
					has_trait = paranoid
				}
				modifier = { #Traits
					add = 10
					has_trait = diligent
				}
				modifier = { #Traits
					add = 10
					has_trait = ambitious
				}
				modifier = { #Traits
					add = 10
					has_trait = impatient
				}
				modifier = { #Energy
					add = 10
					ai_energy > low_positive_energy
				}
				modifier = { #Stress
					add = 10
					stress < normal_baseline_stress
				}
			}
		}
        stress_impact = {
        	chaste = minor_stress_impact_loss
			lazy = medium_stress_impact_loss
			lustful = minor_stress_impact_gain
			rakish = minor_stress_impact_gain
			deviant = minor_stress_impact_gain
        }
        ai_chance = {
            base = 70
            ai_value_modifier = {
				ai_greed = -0.10
				ai_energy = -0.35
   			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = 20
				has_trait = lazy
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = shy
			}
			modifier = {
				add = 15
				any_child = {
					count >= 4
				}
			}
        }
    }
	after = {
		add_character_flag = {
			flag = chosen_night_companion
			years = 4
		}
	}
}

#################################
##Poisoning an unwanted consort##
#################################
scripted_trigger unwanted_consort_trigger = {
	save_temporary_scope_as = reference_unwanted_consort
	OR = {
		any_close_family_member = {
			OR = {
				is_powerful_vassal_of = root
				is_councillor_of = root
				is_liege_or_above_of = root
			
			}
			NOT = {
				is_child_of = root
			}
		}
		num_of_bad_genetic_traits > 0
		has_relation_nemesis = root
		has_relation_rival = root
		any_secret = { 
			is_known_by = root
			is_criminal_for = secret_owner
		}
		root = {
			has_imprisonment_reason = scope:reference_unwanted_consort
		}
	}
	age <= 44
	is_courtier_of = root
	is_physically_able_ai_adult = yes
	is_demoted_consort_trigger = no
	harem_politics_beloved_consort_trigger = no
	harem_politics_forgotten_consort_trigger = no
	NOR = {
		has_trait = pregnant
		
		has_character_modifier = hua_fei_fragrance_modifier
		has_character_modifier = shu_fei_conception_medicine_modifier
		has_character_modifier = rejected_from_marriage_bed_modifier
		has_character_modifier = langhua_bracelet_modifier
		has_character_modifier = lingrong_ointment_modifier

		has_character_modifier = favor_boost_modifier
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0012 = {
	type = character_event
	title = harem_politics.0012.t
	desc = {
		desc = harem_politics.0012.start.desc
		first_valid = {
			triggered_desc = { #Do they have a powerful background?
				trigger = {
					scope:unwanted_consort = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								is_liege_or_above_of = root
							}
						}
					}
				}
				desc = harem_politics.0012.powerful_consort.desc
			}
			triggered_desc = { #Negative traits
				trigger = {
					scope:unwanted_consort = {
						num_of_bad_genetic_traits >= 1
					}
				}
				desc = harem_politics.0012.negative_traits.desc
			}
			triggered_desc = { #Criminal
				trigger = {
					OR = {
						has_imprisonment_reason = scope:unwanted_consort
						scope:unwanted_consort = {
							any_secret = { 
								is_known_by = root
								is_criminal_for = secret_owner
							}
						}
					}
				}
				desc = harem_politics.0012.criminal.desc
			}
			triggered_desc = { #Rival
				trigger = {
					OR = {
						has_relation_nemesis = scope:unwanted_consort
						has_relation_rival = scope:unwanted_consort
						has_relation_potential_rival = scope:unwanted_consort
					}
				}
				desc = harem_politics.0012.rival.desc
			}
		}
		desc = harem_politics.0012.end.desc
	}
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:unwanted_consort
		animation = admiration
	}
	
	trigger = {
		any_consort = {
			unwanted_consort_trigger = yes
		}
		NOT = {
			has_character_flag = poisoned_a_consort_flag
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		highest_held_title_tier >= tier_kingdom
		is_female = no
	}
	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.2
			any_child = {
				count <= 2
			}
		}
		modifier = {
			add = 0.2
			has_trait = paranoid
		}
		modifier = {
			add = -0.5
			has_trait = trusting
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				unwanted_consort_trigger = yes
			}
			add_to_list = unwanted_consort_list
		}
		
		random_in_list = {
			list = unwanted_consort_list
			weight = {
				base = 10
				modifier = {
					has_character_flag = flag_new_consort
					add = 20
				}
				modifier = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_liege_or_above_of = root
						}
					}
					add = 30
				}
				modifier = {
					any_close_family_member = {
						is_councillor_of = root
					}
					add = 20
				}
				modifier = {
					num_of_bad_genetic_traits > 0
					add = 1
				}
				modifier = {
					num_of_bad_genetic_traits > 1
					add = 20
				}
				modifier = {
					any_close_family_member = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
						}
					}
					add = 20
				}
				modifier = {
					OR = {
						has_relation_nemesis = root
						has_relation_rival = root
						has_relation_potential_rival = root
					}
					add = 20
				}
				modifier = {
					NOT = {
						this = root.primary_spouse
					}
					add = 25
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = -10
				}
			}
			save_scope_as = unwanted_consort
		}
	}
	
	option = { # Consort Shu's medicine
        name = harem_politics.0012.a
		duel = {
			target = scope:unwanted_consort
			skill = intrigue
			80 = {
				compare_modifier = {
					value = scope:duel_value
				}
				opinion_modifier = {
					who = scope:unwanted_consort
					opinion_target = root
					min = -10
					max = 10
					multiplier = 0.1
				}
				scope:unwanted_consort = {
					calyver_favor_huge_gain_effect = yes
					add_character_modifier = {
						modifier = shu_fei_conception_medicine_modifier
						years = 5
					}
					if = {
						limit = {
							opinion = {
								target = root
								value >= -10
							}
						}
						add_opinion = {
							target = root
							modifier = romance_opinion
							opinion = 5
						}
						if = {
							limit = { can_set_relation_potential_lover_trigger = { CHARACTER = root } }
							set_relation_potential_lover = root
						}
					}
				}
				hidden_effect = {
					every_consort = {
						limit = {
							NOT = {
								this = scope:unwanted_consort
							}
							OR = {
								hp_accepts_concubinage = yes
								hp_accepts_polygamy = yes
							}
							NOT = {
								has_opinion_modifier = {
									modifier = forced_me_concubine_marriage_opinion
									target = root
								}
							}
							harem_politics_evil_consort_trigger = yes
							opinion = {
								target = root
								value >= -10
							}
							opinion = {
								target = scope:unwanted_consort
								value <= 15
							}
						}
						add_opinion = {
							target = scope:unwanted_consort
							modifier = jealousy_opinion
							opinion = -5
						}
					}
				}
			}
			20 = {
				desc = harem_politics.0012.a.defeat
				compare_modifier = {
					value = scope:duel_value
				}
				modifier = { #Traits
					add = 50
					scope:unwanted_consort = {
						has_trait = lifestyle_herbalist
					}
				}
				opinion_modifier = {
					who = scope:unwanted_consort
					opinion_target = root
					min = -20
					max = 20
					multiplier = -0.2
				}
				scope:unwanted_consort = {
					calyver_favor_medium_loss_effect = yes
					hidden_effect = {
						if = {
							limit = {
								any_close_family_member = {
									NOR = { 
										this = scope:unwanted_consort
										this = root
									}
									count >= 1
								}
							}
							every_close_family_member = {
								limit = { 
									NOR = { 
										this = scope:unwanted_consort
										this = root
									} 
								}
								add_opinion = {
									target = root
									modifier = suspicion_opinion
									opinion = -10
								}
							}
						}
					}
					add_opinion = {
						target = root
						modifier = suspicion_opinion
						opinion = -15
					}
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_honor = -0.15
				ai_compassion = -0.15
				ai_boldness = 0.20
   			}
			opinion_modifier = {
				opinion_target = scope:unwanted_consort
				multiplier = -0.20
				min = -10
				max = 10
			}
			modifier = {
            	add = 20
            	intrigue > medium_skill_rating
            }
			modifier = {
            	add = -25
            	has_trait = trusting
            }
			modifier = {
            	add = 10
            	has_trait = paranoid
            }
			modifier = {
            	add = -25
            	has_trait = compassionate
            }
			modifier = {
            	add = -25
            	has_trait = forgiving
            }
			modifier = {
            	add = -25
            	has_trait = honest
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		intrigue < medium_skill_rating
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		harem_politics_evil_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits = 1
            	}
            }
			modifier = {
            	add = -20
            	scope:unwanted_consort = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						is_vassal_of = root
					}
            	}
            }
			modifier = {
            	add = 15
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_liege_or_above_of = root
						}
					}
            	}
            }
			modifier = {
            	add = 15
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
						}
					}
            	}
            }
			modifier = {
            	add = 15
				OR = {
					scope:unwanted_consort = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
							any_secret = { 
								is_known_by = root
								is_criminal_for = secret_owner
							}
						}
					}
					has_imprisonment_reason = scope:unwanted_consort
				}
            }
			modifier = {
            	add = -25
            	OR = {
            		has_relation_lover = scope:unwanted_consort
					has_relation_soulmate = scope:unwanted_consort
            	}
            }
			modifier = {
            	add = -15
            	OR = {
            		has_relation_best_friend = scope:unwanted_consort
					has_relation_friend = scope:unwanted_consort
            	}
            }
			modifier = {
				add = -20
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { # Consort Hua's incense
        name = harem_politics.0012.b
		duel = {
			target = scope:unwanted_consort
			skill = intrigue
			80 = {
				compare_modifier = {
					value = scope:duel_value
				}
				opinion_modifier = {
					who = scope:unwanted_consort
					opinion_target = root
					min = -10
					max = 10
					multiplier = 0.1
				}
				scope:unwanted_consort = {
					calyver_favor_huge_gain_effect = yes
					add_character_modifier = {
						modifier = hua_fei_fragrance_modifier
						years = 5
					}
					if = {
						limit = {
							opinion = {
								target = root
								value >= -10
							}
						}
						add_opinion = {
							target = root
							modifier = romance_opinion
							opinion = 5
						}
						if = {
							limit = { can_set_relation_potential_lover_trigger = { CHARACTER = root } }
							set_relation_potential_lover = root
						}
					}
				}
				hidden_effect = {
					every_consort = {
						limit = {
							NOT = {
								this = scope:unwanted_consort
							}
							OR = {
								hp_accepts_concubinage = yes
								hp_accepts_polygamy = yes
							}
							NOT = {
								has_opinion_modifier = {
									modifier = forced_me_concubine_marriage_opinion
									target = root
								}
							}
							harem_politics_evil_consort_trigger = yes
							opinion = {
								target = root
								value >= -10
							}
							opinion = {
								target = scope:unwanted_consort
								value <= 15
							}
						}
						add_opinion = {
							target = scope:unwanted_consort
							modifier = jealousy_opinion
							opinion = -5
						}
					}
				}
			}
			20 = {
				desc = harem_politics.0012.a.defeat
				compare_modifier = {
					value = scope:duel_value
				}
				modifier = { #Traits
					add = 50
					scope:unwanted_consort = {
						has_trait = lifestyle_herbalist
					}
				}
				opinion_modifier = {
					who = scope:unwanted_consort
					opinion_target = root
					min = -20
					max = 20
					multiplier = -0.2
				}
				scope:unwanted_consort = {
					calyver_favor_medium_loss_effect = yes
					hidden_effect = {
						if = {
							limit = {
								any_close_family_member = {
									NOR = { 
										this = scope:unwanted_consort
										this = root
									}
									count >= 1
								}
							}
							every_close_family_member = {
								limit = { 
									NOR = { 
										this = scope:unwanted_consort
										this = root
									} 
								}
								add_opinion = {
									target = root
									modifier = suspicion_opinion
									opinion = -10
								}
							}
						}
					}
					add_opinion = {
						target = root
						modifier = suspicion_opinion
						opinion = -15
					}
				}
			}
			10 = {
				show_as_tooltip = { #we wanna show this
					scope:unwanted_consort = {
						death = { death_reason = death_mysterious }
					}
					add_secret = {
						type = secret_murder
						target = scope:unwanted_consort
					}
				}
				hidden_effect = { #this does the effect
					unknown_murder_effect = {
						VICTIM = scope:unwanted_consort
						MURDERER = root
						REASON = death_mysterious
					}
				}
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			honest = minor_stress_impact_gain
			trusting = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_honor = -0.15
				ai_compassion = -0.15
				ai_boldness = 0.30
   			}
			opinion_modifier = {
				opinion_target = scope:unwanted_consort
				multiplier = -0.30
			}
			modifier = {
            	add = 10
            	has_trait = paranoid
            }
			modifier = {
            	add = -25
            	has_trait = compassionate
            }
			modifier = {
            	add = -25
            	has_trait = trusting
            }
			modifier = {
            	add = -25
            	has_trait = forgiving
            }
			modifier = {
            	add = -25
            	has_trait = honest
            }
			modifier = {
            	add = 20
            	intrigue >= high_skill_rating
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		intrigue < medium_skill_rating
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		harem_politics_evil_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits = 1
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits >= 2
            	}
            }
			modifier = {
            	add = -25
            	scope:unwanted_consort = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = -15
            	scope:unwanted_consort = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = -15
            	scope:unwanted_consort = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						is_vassal_of = root
					}
            	}
            }
			modifier = {
            	add = -15
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_liege_or_above_of = root
						}
					}
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
						}
					}
            	}
            }
			modifier = {
            	add = 20
				OR = {
					scope:unwanted_consort = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
							any_secret = { 
								is_known_by = root
								is_criminal_for = secret_owner
							}
						}
					}
					has_imprisonment_reason = scope:unwanted_consort
				}
            }
			modifier = {
            	add = -35
            	OR = {
            		has_relation_lover = scope:unwanted_consort
					has_relation_soulmate = scope:unwanted_consort
            	}
            }
			modifier = {
            	add = -30
            	OR = {
            		has_relation_best_friend = scope:unwanted_consort
					has_relation_friend = scope:unwanted_consort
            	}
            }
			modifier = {
				add = -25
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { # I'll just stop seeing them
        name = harem_politics.0012.c
		scope:unwanted_consort = {
			calyver_favor_big_loss_effect = yes
			add_character_modifier = {
				modifier = rejected_from_marriage_bed_modifier
				years = 10
			}
			if = {
				limit = {
					OR = {
						hp_accepts_concubinage = yes
						hp_accepts_polygamy = yes
					}
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					opinion = {
						target = root
						value >= -10
					}
				}
				add_opinion = {
					target = root
					modifier = insult_opinion
					opinion = -20
				}
			}
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			chaste = minor_stress_impact_loss
			trusting = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_vengefulness = -0.10
				ai_honor = 0.15
				ai_compassion = -0.15
				ai_boldness = 0.10
   			}
			opinion_modifier = {
				opinion_target = scope:unwanted_consort
				multiplier = -0.30
			}
			modifier = {
            	add = -25
            	has_trait = trusting
            }
			modifier = {
            	add = -25
            	has_trait = compassionate
            }
			modifier = {
            	add = -25
            	has_trait = forgiving
            }
			modifier = {
            	add = 15
            	has_trait = chaste
            }
			modifier = {
            	add = -25
            	has_trait = lustful
            }
			modifier = {
            	add = 10
            	has_trait = paranoid
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		is_lowborn = no
            	}
            }
			modifier = {
            	add = -15
            	scope:unwanted_consort = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		harem_politics_evil_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits = 1
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits >= 2
            	}
            }
			modifier = {
            	add = -35
            	scope:unwanted_consort = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = -20
            	scope:unwanted_consort = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = -15
            	scope:unwanted_consort = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						is_vassal_of = root
					}
            	}
            }
			modifier = {
            	add = -20
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_liege_or_above_of = root
						}
					}
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
						}
					}
            	}
            }
			modifier = {
            	add = 10
				OR = {
					scope:unwanted_consort = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
							any_secret = { 
								is_known_by = root
								is_criminal_for = secret_owner
							}
						}
					}
					has_imprisonment_reason = scope:unwanted_consort
				}
            }
			modifier = {
            	add = -35
            	OR = {
            		has_relation_lover = scope:unwanted_consort
					has_relation_soulmate = scope:unwanted_consort
            	}
            }
			modifier = {
            	add = -35
            	OR = {
            		has_relation_best_friend = scope:unwanted_consort
					has_relation_friend = scope:unwanted_consort
            	}
            }
			modifier = {
				add = -25
				any_child = {
					count <= 1
				}
			}
        }
    }
	
	option = { #Forget it
		name = harem_politics.0012.d
		stress_impact = {
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_vengefulness = -0.10
				ai_honor = 0.15
				ai_compassion = 0.15
				ai_boldness = -0.10
   			}
			opinion_modifier = {
				opinion_target = scope:unwanted_consort
				multiplier = 0.30
			}
			modifier = {
            	add = -25
            	has_trait = paranoid
            }
			modifier = {
            	add = 25
            	has_trait = trusting
            }
			modifier = {
            	add = 5
            	scope:unwanted_consort = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		num_of_bad_genetic_traits = 0
            	}
            }
			modifier = {
            	add = 20
            	scope:unwanted_consort = {
            		num_of_good_genetic_traits >= 1
            	}
            }
			modifier = {
            	add = 15
            	scope:unwanted_consort = {
            		this = root.primary_spouse
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		is_grand_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 5
            	scope:unwanted_consort = {
            		is_married = yes
            	}
            }
			modifier = {
            	add = 10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						is_vassal_of = root
					}
            	}
            }
			modifier = {
            	add = -20
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_liege_or_above_of = root
						}
					}
            	}
            }
			modifier = {
            	add = -10
            	scope:unwanted_consort = {
            		any_close_family_member = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
						}
					}
            	}
            }
			modifier = {
            	add = -20
				OR = {
					scope:unwanted_consort = {
						OR = {
							has_relation_nemesis = root
							has_relation_rival = root
							has_relation_potential_rival = root
							any_secret = { 
								is_known_by = root
								is_criminal_for = secret_owner
							}
						}
					}
					has_imprisonment_reason = scope:unwanted_consort
				}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:unwanted_consort
					has_relation_soulmate = scope:unwanted_consort
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:unwanted_consort
					has_relation_friend = scope:unwanted_consort
            	}
            }
			modifier = {
				add = -25
				any_child = {
					count >= 4
				}
			}
        }
	}
	
	after = {
		add_character_flag = {
			flag = poisoned_a_consort_flag
			years = 4
		}
	}
}

########################
##Qi is jealous of Xin##
########################
scripted_trigger harem_politics_xin_trigger = {
	is_physically_able_ai_adult = yes
	is_healthy = yes
	is_courtier_of = root

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_evil_consort_trigger = no

	hp_accepts_harems = yes

	opinion = {
		target = root
		value > -15
	}

	NOR = {
		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}

		this = $QI$

		has_relation_best_friend = $QI$
		has_relation_friend = $QI$

		has_relation_soulmate = $QI$
		has_relation_lover = $QI$
		has_relation_potential_lover = $QI$
		
		has_trait = pregnant
		has_trait = ill
		has_trait = wounded
		
		has_trait = chaste

		has_character_modifier = favor_boost_modifier
		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_qi_trigger = {
	is_physically_able_ai_adult = yes
	is_healthy = yes
	is_courtier_of = root

	is_demoted_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_evil_consort_trigger = yes

	hp_accepts_harems = yes

	opinion = {
		target = root
		value > -15
	}

	NOR = {
		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		has_court_position = grand_consort_court_position
		
		has_trait = pregnant
		has_trait = ill
		has_trait = wounded

		has_trait = calm
		has_trait = craven
		has_trait = shy
		has_trait = temperate
		has_trait = chaste
		has_trait = humble

		has_character_modifier = favor_boost_modifier

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0013 = {
	type = character_event
	title = harem_politics.0013.t
	desc = harem_politics.0013.desc
	theme = family
	override_background = {
		reference = bedchamber
	}

	
	left_portrait  = {
		character = root
		animation = boredom
	}
	right_portrait = {
		character = scope:qi_pin
		animation = worry
	}
	lower_center_portrait = {
		character = scope:xin_guiren
	}
	
	trigger = {
		exists = scope:qi_pin
		exists = scope:xin_guiren
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	
	immediate = {
		show_as_tooltip = {
			had_sex_with_effect = {
				CHARACTER = scope:xin_guiren
				PREGNANCY_CHANCE = pregnancy_chance
			}	
		}
		hidden_effect = {
			scope:xin_guiren = {
				add_opinion = {
					target = scope:qi_pin
					modifier = insult_opinion
					opinion = -10
				}
			}
		}
		if = {
			limit = {
				NOT = {
					has_trait = lustful
				}
			}
			stress_impact = {
				base = minor_stress_impact_loss
			}
		}
	}
	
	option = { # Stay with Xin GuiRen
        name = harem_politics.0013.a
		add_character_flag = {
			flag = flag_qi_pin_xin_guiren_event
			years = 4
		}
		hidden_effect = {
			had_sex_with_effect = {
				CHARACTER = scope:xin_guiren
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}
		scope:xin_guiren = {
			calyver_favor_moderate_gain_effect = yes
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 10
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					} 
				}
				set_relation_potential_lover = root
			}
		}
		scope:qi_pin = {
			calyver_favor_moderate_loss_effect = yes
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:qi_pin
				}
			}
			add_opinion = {
				target = root
				modifier = ignored_consort_opinion
				opinion = -10
			}
			add_opinion = {
				target = scope:xin_guiren
				modifier = jealousy_opinion
				opinion = -5
			}
			if = {
				limit = { 
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:xin_guiren }
				}
				set_relation_potential_rival = scope:xin_guiren
			}
			add_character_flag = {
				flag = flag_scolded_consort
				years = 2
			}
		}
		add_opinion = {
			target = scope:qi_pin
			modifier = insolent_consort_opinion
			opinion = -10
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			craven = minor_stress_impact_gain
		}
		ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_honor = 0.20
				ai_boldness = 0.20
				ai_energy = -0.25
				ai_rationality = 0.20
   			}
			opinion_modifier = {
				opinion_target = scope:qi_pin
				multiplier = -0.30
			}
			opinion_modifier = {
				opinion_target = scope:xin_guiren
				multiplier = 0.30
			}
			modifier = {
				add = -10
				scope:qi_pin = {
					is_married = yes
				}
			}
			modifier = {
				add = 10
				scope:xin_guiren = {
					is_married = yes
				}
			}
			modifier = {
				add = 10
				scope:xin_guiren = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = 15
				has_trait = chaste
			}
			modifier = {
				add = 15
				has_trait = shy
			}
			modifier = {
				add = -25
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = craven
			}
			modifier = {
				add = 10
				scope:xin_guiren = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:xin_guiren = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -10
				scope:xin_guiren = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:xin_guiren = {
					has_character_modifier = forgotten_consort_modifier
				}
			}
        }
    }
	
	option = { # Go with Qi Pin
        name = harem_politics.0013.b
		had_sex_with_effect = {
			CHARACTER = scope:qi_pin
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:qi_pin = {
			calyver_favor_moderate_gain_effect = yes
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 10
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					} 
				}
				set_relation_potential_lover = root
			}
		}
		scope:xin_guiren = {
			calyver_favor_moderate_loss_effect = yes
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:xin_guiren
				}
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
			add_opinion = {
				target = scope:qi_pin
				modifier = hatred_spouse_opinion
			}
			if = {
				limit = { 
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:qi_pin } 
				}
				set_relation_potential_rival = scope:qi_pin
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_honor = -0.20
				ai_boldness = -0.20
				ai_energy = 0.25
				ai_rationality = -0.20
   			}
			opinion_modifier = {
				opinion_target = scope:qi_pin
				multiplier = 0.30
			}
			opinion_modifier = {
				opinion_target = scope:xin_guiren
				multiplier = -0.30
			}
			modifier = {
				add = 15
				has_trait = lustful
			}
			modifier = {
				add = 15
				has_trait = craven
			}
			modifier = {
				add = -25
				has_trait = chaste
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = -25
				has_trait = just
			}
			modifier = {
				add = 10
				scope:qi_pin = {
					is_married = yes
				}
			}
			modifier = {
				add = -10
				scope:xin_guiren = {
					is_married = yes
				}
			}
			modifier = {
				add = -5
				scope:xin_guiren = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = 10
				scope:qi_pin = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
					}
				}
			}
			modifier = {
				add = 10
				scope:qi_pin = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:qi_pin = {
					has_character_modifier = beloved_consort_modifier
				}
			}
        }
    }
}

#####################################
##A punished consort is complaining##
#####################################

scripted_effect punishment_consort_opinion_mild_effect = {
	if = {
		limit = {
			NOR = {
				has_trait = forgiving
				has_trait = compassionate
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = vengeful
					has_trait = callous
					has_trait = sadistic
				}
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
		else = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
	}
	else = {
		add_opinion = {
			target = root
			modifier = cruelty_opinion
			opinion = -5
		}
	}
	
	calyver_favor_medium_gain_effect = yes
}

scripted_effect punishment_consort_opinion_big_effect = {
	if = {
		limit = {
			NOR = {
				has_trait = forgiving
				has_trait = compassionate
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = vengeful
					has_trait = callous
					has_trait = sadistic
				}
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		else = {
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 15
			}
		}
	}
	else = {
		add_opinion = {
			target = root
			modifier = cruelty_opinion
			opinion = -15
		}
	}
	calyver_favor_big_gain_effect = yes
}

harem_politics.0014 = {
	type = character_event
	title = harem_politics.0014.t
	desc = {
		desc = harem_politics.0014.start.desc
		first_valid = {
			triggered_desc = { #Torture
				trigger = {
					scope:recipient = {
						has_character_modifier = recently_tortured
					}
				}
				desc = harem_politics.0014.torture.desc
			}
			triggered_desc = { #Lashes
				trigger = {
					scope:recipient = {
						has_character_modifier = hunt_tasted_the_belt_modifier
					}
				}
				desc = harem_politics.0014.lashes.desc
			}
			triggered_desc = { #Generic punishment
				desc = harem_politics.0014.gp.desc
			}
		}
		desc = harem_politics.0014.end.desc
	}
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = root
		animation = boredom
	}
	right_portrait = {
		character = scope:beggar
		animation = beg
	}
	lower_center_portrait = {
		character = scope:recipient
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		scope:recipient = {
			is_physically_able_ai_adult = yes
			is_valid_harem_member_trigger = {
				LIEGE = root
			}
			OR = {
				AND = {
					is_travelling = yes
					current_travel_plan = {
						travel_plan_owner = root
					}
				}
				AND = {
					is_travelling = no
					root = {
						is_travelling = no
					}
				}
			}
		}
		scope:beggar = {
			is_physically_able_ai_adult = yes
			is_valid_harem_member_trigger = {
				LIEGE = root
			}
			OR = {
				AND = {
					is_travelling = yes
					current_travel_plan = {
						travel_plan_owner = root
					}
				}
				AND = {
					is_travelling = no
					root = {
						is_travelling = no
					}
				}
			}
		}
		NOT = {
			this = scope:recipient
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		if = {
			limit = {
				exists = scope:actor
			}
			clear_saved_scope = actor
		}
		save_scope_as = actor
	}
	
	option = { # Scold the recipient
        name = harem_politics.0014.a
		if = {
			limit = {
				AND = {
					scope:beggar = {
						OR = {
							has_trait = wounded
							has_character_modifier = recently_tortured
						}
					}
					OR = {
						has_trait = compassionate
						has_trait = forgiving
					}
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = cruelty_opinion
				opinion = -15
			}
		}
		else_if = {
			limit = {
				AND = {
					scope:beggar = {
						OR = {
							has_trait = wounded
							has_character_modifier = recently_tortured
						}
					}
					NOR = {
						has_trait = sadistic
						has_trait = vengeful
						has_trait = callous
					}
				}
			}
			add_opinion = {
				target = scope:recipient
				modifier = cruelty_opinion
				opinion = -10
			}
		}
		else = {
			add_opinion = {
				target = scope:recipient
				modifier = cruelty_opinion
				opinion = -5
			}
		}
		scope:recipient = {
			if = {
				limit = {
					is_consort_of = root
				}
				calyver_favor_minor_loss_effect = yes
				add_character_flag = {
					flag = flag_scolded_consort
					years = 1
				}
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
			hidden_effect = {
				add_opinion = {
					target = scope:beggar
					modifier = hatred_spouse_opinion
				}
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:beggar } 
				}
				set_relation_potential_rival = scope:beggar
			}
		}
		scope:beggar = {
			if = {
				limit = {
					NOR = {
						has_trait = sadistic
						has_trait = callous
						has_trait = vengeful
					}
				}
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 5
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
			calyver_favor_minor_gain_effect = yes
		}
		
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.10
				ai_energy = -0.15
				ai_rationality = -0.10
   			}
			modifier = { #Player heir
				add = 10
				scope:beggar = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = { #Player heir
				add = 5
				scope:recipient = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = {
				add = -20
				scope:recipient = {
					has_trait = pregnant
				}
			}
			opinion_modifier = {
				opinion_target = scope:beggar
				multiplier = 0.20
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = -0.50
			}
			
			modifier = {
				add = -20
				has_trait = sadistic
			}
			modifier = {
				add = -20
				has_trait = callous
			}
			modifier = {
				add = -20
				has_trait = vengeful
			}
			modifier = {
				add = 5
				scope:beggar = {
					is_married = yes
				}
			}
			modifier = {
				add = 5
				scope:beggar = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					is_married = yes
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -15
				scope:recipient = {
					this = root.primary_spouse
				}
			}

			modifier = {
				add = -10
				scope:beggar = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:beggar = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -15
				scope:beggar = {
					has_character_modifier = favor_boost_modifier
				}
			}
			
			modifier = {
				add = -10
				scope:recipient = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:recipient = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -15
				scope:recipient = {
					has_character_modifier = favor_boost_modifier
				}
			}

			modifier = {
				add = -30
				scope:recipient = {
					any_child = {
						this = root
					}
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = -20
				scope:recipient = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			modifier = {
				add = 15
				scope:beggar = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			#Powerful consorts
			modifier = {
				add = -20
				scope:beggar = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -5
				scope:beggar = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -5
				scope:beggar = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}

			modifier = {
				add = -15
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}
        }
    }
	
	option = { # Punish the recipient
        name = harem_politics.0014.b
		trigger = {
			NOR = {
				this = scope:recipient
				scope:recipient = {
					has_trait = pregnant
				}
			}
			scope:recipient = {
				is_consort_of = root
			}
			OR = {
				has_trait = sadistic
				has_trait = vengeful
				has_trait = callous
			}
		}

		scope:recipient = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:recipient
				}
			}
			calyver_favor_medium_loss_effect = yes
			hidden_effect = {
				add_opinion = {
					target = scope:beggar
					modifier = hatred_spouse_opinion
				}
			}
			add_character_flag = {
				flag = is_being_tortured
				months = 6 # Players in MP can keep the event window open...
			}
			if = {
				limit = {
					is_consort_of = root
				}
				add_character_modifier = {
					modifier = unfavored_consort_modifier
					years = 1
				}
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:beggar }
				}
				progress_towards_rival_effect = {
					REASON = consort_rival_reason
					CHARACTER = scope:beggar
					OPINION = 0
				}
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = root } 
				}
				set_relation_potential_rival = root
			}
		}
		scope:beggar = {
			punishment_consort_opinion_big_effect = yes
		}

		###EFFECT TOOLTIP###
		torture_interaction_actor_effect = yes
		show_as_tooltip = {
			scope:recipient = {
				add_character_modifier = {
					modifier = recently_tortured
					years = 5
				}
			}
		}

		###EVENTS###
		hidden_effect = {
			#Torture method for descs
			random_list = {
				3 = { save_scope_value_as = { name = torture_method value = flag:rack } }
				3 = { save_scope_value_as = { name = torture_method value = flag:whip } }
				1 = { save_scope_value_as = { name = torture_method value = flag:rats } }
				8 = {
					trigger = {
						scope:actor = { has_trait = poet }
					}
					save_scope_value_as = {
						name = torture_method
						value = flag:poetry
					}
				}
			}

			#They have a secret I want to know about
			if = {
				limit = {
					scope:recipient = {	
						OR = {
							any_secret = {
								torture_secret_trigger = { PARTICIPANT = scope:recipient }
							}
							any_known_secret = {
								secret_owner = { save_temporary_scope_as = torture_secret_owner }
								torture_secret_trigger = { PARTICIPANT = scope:torture_secret_owner }
							}
						}
					}
				}
				scope:recipient = {
					trigger_event = {
						id = prison_c.1001
						days = 1
					}
				}
			}
			else = {
				scope:actor = {
					trigger_event = {
						id = prison_c.1010
						days = 1
					}
				}
			}	
		}

		# Dark Insights Perk:
		if = {
			limit = {
				scope:actor = { has_perk = dark_insights_perk }
			}
			scope:actor = {
				dark_insights_skill_gain_roll_effect = yes
			}
		}
		
		if = {
			limit = {
				AND = {
					scope:recipient = {
						is_parent_of = root
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
			}
			add_character_modifier = {
				modifier = unfilial_opinion_modifier
				years = 10
			}
		}
		stress_impact = {
			callous = medium_stress_impact_loss
		}

        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.15
				ai_energy = 0.15
				ai_rationality = -0.15
   			}
			modifier = { #Player heir
				add = 5
				scope:beggar = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = { #Player heir
				add = -30
				scope:recipient = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = {
				add = -25
				scope:recipient = {
					has_trait = pregnant
				}
			}

			modifier = {
				add = 10
				scope:beggar = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:beggar = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:beggar = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:beggar = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = -20
				scope:recipient = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -30
				scope:recipient = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -25
				scope:recipient = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:recipient = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			opinion_modifier = {
				opinion_target = scope:beggar
				multiplier = 0.40
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = -0.60
			}
			modifier = {
				add = -25
				has_trait = forgiving
			}
			modifier = {
				add = -25
				has_trait = compassionate
			}
			modifier = {
				add = 20
				has_trait = sadistic
			}
			modifier = {
				add = 20
				has_trait = callous
			}
			modifier = {
				add = 20
				has_trait = vengeful
			}
			modifier = {
				add = 10
				scope:beggar = {
					is_married = yes
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					is_married = yes
				}
			}
			modifier = {
				add = -15
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -60
				scope:recipient = {
					this = root.primary_spouse
				}
			}
			modifier = {
				add = -200
				scope:recipient = {
					any_child = {
						this = root
					}
				}
			}
			
			#Powerful consorts
			modifier = {
				add = 20
				scope:beggar = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}

			modifier = {
				add = -25
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			
			modifier = {
				add = -20
				scope:recipient = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = -50
				scope:recipient = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			modifier = {
				add = 15
				scope:beggar = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = 30
				scope:beggar = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					has_character_modifier = recently_tortured
				}
			}
			modifier = {
				factor = 0
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
        }
    }
	
	option = { # Imprison the recipient
        name = harem_politics.0014.c
		scope:recipient = {
			if = {
				limit = {
					is_consort_of = root
				}
				calyver_favor_moderate_loss_effect = yes
				if = {
					limit = {
						has_character_modifier = favor_boost_modifier
					}
					calyver_stop_favor_boost_event_effect = {
						HAREM_LIEGE = root
						CONSORT = scope:recipient
					}
				}
			}
			hidden_effect = {
				add_opinion = {
					target = scope:beggar
					modifier = hatred_spouse_opinion
				}
			}
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -20
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:beggar }
				}
				progress_towards_rival_effect = {
					REASON = consort_rival_reason
					CHARACTER = scope:beggar
					OPINION = 0
				}
			}
		}
		imprison = {
			target = scope:recipient
			type = house_arrest
		}
		if = {
			limit = {
				AND = {
					scope:recipient = {
						is_parent_of = root
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
			}
			add_character_modifier = {
				modifier = unfilial_opinion_modifier
				years = 10
			}
		}
		scope:beggar = {
			punishment_consort_opinion_mild_effect = yes
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.15
				ai_energy = 0.15
				ai_rationality = -0.15
   			}
			modifier = { #Player heir
				add = 10
				scope:beggar = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = { #Player heir
				add = -10
				scope:recipient = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = {
				add = -25
				scope:recipient = {
					has_trait = pregnant
				}
			}
			
			modifier = {
				add = 10
				scope:beggar = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:beggar = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:beggar = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:beggar = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = -20
				scope:recipient = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -30
				scope:recipient = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -25
				scope:recipient = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:recipient = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			opinion_modifier = {
				opinion_target = scope:beggar
				multiplier = 0.20
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = -0.30
			}
			modifier = {
				add = -15
				has_trait = forgiving
			}
			modifier = {
				add = -15
				has_trait = compassionate
			}
			modifier = {
				add = 10
				has_trait = sadistic
			}
			modifier = {
				add = 10
				has_trait = callous
			}
			modifier = {
				add = 10
				has_trait = vengeful
			}
			modifier = {
				add = 5
				scope:beggar = {
					is_married = yes
				}
			}
			modifier = {
				add = 5
				scope:beggar = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					is_married = yes
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -60
				scope:recipient = {
					this = root.primary_spouse
				}
			}
			modifier = {
				add = -200
				scope:recipient = {
					any_child = {
						this = root
					}
				}
			}
			
			#Powerful consorts
			modifier = {
				add = 15
				scope:beggar = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}

			modifier = {
				add = -25
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			
			modifier = {
				add = -20
				scope:recipient = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = -50
				scope:recipient = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			modifier = {
				add = 10
				scope:beggar = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = 25
				scope:beggar = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			modifier = {
				factor = 0
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				scope:recipient = {
					NOT = {
						is_consort_of = root
					}
				}
				factor = 0
			}
        }
		trigger_event = harem_politics.1000
    }
	
	option = { # Demote the recipient
        name = harem_politics.0014.d
		trigger = {
			#The recipient isn't the close relative of our liege
			scope:recipient = {
				NOR = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
					has_strong_hook = root
				}
				is_consort_of = root
			}
			OR = {
				#Revoking GC position
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
				#Demoting from spouse to concubine
				AND = {
					scope:recipient = {
						NOT = { 
							has_court_position = grand_consort_court_position
						}
					}
					is_character_interaction_valid = {
						recipient = scope:recipient
						interaction = demote_spouse_interaction
					}
				}
			}
		}
		if = {
			limit = {
				AND = {
					scope:recipient = {
						is_parent_of = root
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
			}
			add_character_modifier = {
				modifier = unfilial_opinion_modifier
				years = 10
			}
		}
		scope:recipient = {
			hidden_effect = {

				add_opinion = {
					target = scope:beggar
					modifier = hatred_spouse_opinion
				}
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:beggar } 
				}
				set_relation_potential_rival = scope:beggar
			}
		}
		if = {
			limit = {
				scope:recipient = {
					NOT = { 
						has_court_position = grand_consort_court_position
					}
				}
				is_character_interaction_valid = {
					recipient = scope:recipient
					interaction = demote_spouse_interaction
				}
			}
			run_interaction = {
				interaction = demote_spouse_interaction
				actor = scope:harem_liege
				recipient = scope:recipient
				execute_threshold = accept
			}
		}
		else_if = {
			limit = {
				scope:recipient = {
					has_court_position = grand_consort_court_position
					is_courtier_of = root
					any_close_family_member = {
						NOT = {
							is_liege_or_above_of = root
						}
					}
				}
			}
			revoke_court_position = {
				recipient = scope:recipient
				court_position = grand_consort_court_position
			}
		}
		
		scope:beggar = {
			punishment_consort_opinion_mild_effect = yes
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.15
				ai_energy = 0.15
				ai_rationality = -0.15
   			}
			modifier = { #Alliance
				scope:recipient = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -30
			}
			modifier = { #Player heir
				add = 5
				scope:beggar = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = { #Player heir
				add = -20
				scope:recipient = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			modifier = {
				add = -15
				scope:recipient = {
					has_trait = pregnant
				}
			}
			
			modifier = {
				add = 10
				scope:beggar = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:beggar = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:beggar = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:beggar = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = -20
				scope:recipient = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -30
				scope:recipient = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -25
				scope:recipient = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:recipient = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			opinion_modifier = {
				opinion_target = scope:beggar
				multiplier = 0.20
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = -0.30
			}
			modifier = {
				add = -15
				has_trait = forgiving
			}
			modifier = {
				add = -15
				has_trait = compassionate
			}
			modifier = {
				add = 15
				has_trait = arbitrary
			}
			modifier = {
				add = -10
				scope:recipient = {
					has_character_flag = flag_new_consort
				}
			}
			modifier = {
				add = 5
				scope:beggar = {
					is_married = yes
				}
			}
			modifier = {
				add = 5
				scope:beggar = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					is_married = yes
				}
			}
			modifier = {
				add = -5
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = -60
				scope:recipient = {
					this = root.primary_spouse
				}
			}
			modifier = {
				add = -200
				scope:recipient = {
					any_child = {
						this = root
					}
				}
			}
			
			#Powerful consorts
			modifier = {
				add = 15
				scope:beggar = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = 10
				scope:beggar = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}

			modifier = {
				add = -25
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			
			modifier = {
				add = -20
				scope:recipient = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = -50
				scope:recipient = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			modifier = {
				add = 15
				scope:beggar = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = 30
				scope:beggar = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
        }
    }
	
	option = { # Ignore the beggar
        name = harem_politics.0014.e
		stress_impact = {
			callous = miniscule_stress_impact_loss
			lazy = medium_stress_impact_loss
			forgiving = minor_stress_gain
			compassionate = minor_stress_gain
		}
		scope:beggar = {
			calyver_favor_moderate_loss_effect = yes
			if = {
				limit = {
					has_trait = vengeful
					NOR = {
						has_trait = forgiving
						has_trait = compassionate
					}
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -20
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					is_consort_of = root
				}
				calyver_favor_minor_gain_effect = yes
			}
		}
		add_character_flag = flag_dismissed_beggar
		if = {
			limit = {
				AND = {
					scope:beggar = {
						is_parent_of = root
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
			}
			add_character_modifier = {
				modifier = unfilial_opinion_modifier
				years = 10
			}
		}
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.10
				ai_rationality = 0.10
   			}
			
			modifier = {
				add = 10
				scope:beggar = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:beggar = {
					has_character_modifier = forgotten_consort_modifier
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:beggar = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = -15
				scope:beggar = {
					has_character_modifier = favor_boost_modifier
				}
			}

			modifier = {
				add = 10
				scope:recipient = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:recipient = {
					has_character_modifier = beloved_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:recipient = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = -10
				scope:recipient = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:recipient = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = { #Player heir
				add = 20
				scope:recipient = {
					any_child = {
						is_player_heir_of = root
					}
				}
			}
			opinion_modifier = {
				opinion_target = scope:beggar
				multiplier = -0.30
			}
			opinion_modifier = {
				opinion_target = scope:recipient
				multiplier = 0.20
			}
			modifier = {
				add = -15
				has_trait = forgiving
			}
			modifier = {
				add = -15
				has_trait = compassionate
			}
			modifier = {
				add = 15
				has_trait = lazy
			}
			modifier = {
				add = 15
				has_trait = cynical
			}
			modifier = {
				add = -25
				has_trait = sadistic
			}
			modifier = {
				add = -25
				has_trait = vengeful
			}
			modifier = {
				add = -25
				has_trait = callous
			}
			modifier = {
				add = -10
				scope:beggar = {
					is_married = yes
				}
			}
			modifier = {
				add = -5
				scope:beggar = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					is_married = yes
				}
			}
			modifier = {
				add = 15
				scope:recipient = {
					has_court_position = grand_consort_court_position
				}
			}
			modifier = {
				add = 20
				exists = primary_spouse
				scope:recipient = {
					this = root.primary_spouse
				}
			}
			modifier = {
				add = 25
				scope:recipient = {
					has_trait = pregnant
				}
			}
			modifier = {
				add = 100
				scope:recipient = {
					any_child = {
						this = root
					}
				}
			}

			#Powerful consorts
			modifier = {
				add = -25
				scope:beggar = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = -10
				scope:beggar = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}

			modifier = {
				add = 25
				scope:recipient = {
					any_close_family_member = {
						is_liege_or_above_of = root
					}
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					any_close_family_member = {
						is_councillor_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			modifier = {
				add = 10
				scope:recipient = {
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = { is_child_of = root }
					}
				}
			}
			
			modifier = {
				add = 20
				scope:recipient = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = 50
				scope:recipient = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
			modifier = {
				add = -20
				scope:beggar = {
					OR = {
						has_relation_lover = root
						has_relation_friend = root
					}
				}
			}
			modifier = {
				add = -40
				scope:beggar = {
					OR = {
						has_relation_best_friend = root
						has_relation_soulmate = root
					}
				}
			}
			
        }
    }
	after = {
		hidden_effect = {
			if = {
				limit = {
					NOT = {
						has_character_flag = flag_dismissed_beggar
					}
					scope:beggar = {
						is_alive = yes
					}
				}
				if = {
					limit = {
						scope:beggar = {
							has_character_modifier = sleep_deprived_modifier
						}
					}
					scope:beggar = {
						remove_character_modifier = sleep_deprived_modifier
					}
				}
				else_if = {
					limit = {
						scope:beggar = {
							has_character_modifier = intrigue_starved_and_deprived_modifier
						}
					}
					scope:beggar = {
						remove_character_modifier = intrigue_starved_and_deprived_modifier
					}
				}
				else = {
					scope:beggar = {
						add_character_modifier = { 
							modifier = safe_disease_treatment_success_high_modifier 
							days = disease_treatment_short_duration 
						}
					}
				}
			}
		}
		if = {
			limit = {
				has_character_flag = flag_dismissed_beggar
			}
			remove_character_flag = flag_dismissed_beggar
		}
	}
}
###################
##Mourning period##
###################
harem_politics.0015 = {
	type = character_event
	title = harem_politics.0015.t
	desc = harem_politics.0015.desc
	theme = death
	
	left_portrait  = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:dead_relation
		animation = idle
	}
	
	trigger = {
		is_physically_able = yes
		is_ruler = yes
		age >=14
		OR = {
			is_betrothed = no
			AND = {
				is_betrothed = yes
				OR = {
					betrothed = {
						age <= 14
					}
					age <= 14
				}
			}
		}
		scope:dead_relation = {
			is_alive = no
		}
	}
	
	immediate = {
	}
	
	option = { # Mourn the relative
        name = harem_politics.0015.a
		flavor = harem_politics.0015.a_tt
		
		if = {
			limit = {
				OR = {
					has_character_flag = dead_important_relative_flag
					has_character_flag = dead_main_spouse_flag
				}
				is_valid_for_legitimacy_change = yes
			}
			add_legitimacy = miniscule_legitimacy_gain
		}
		
		add_character_modifier = {
			modifier = mourner_modifier
			years = 1
		}
		if = {
			limit = {
				has_character_modifier = merry_mourner_modifier
			}
			remove_character_modifier = merry_mourner_modifier
		}
		
		if = {
			limit = {
				has_character_flag = dead_main_spouse_flag
			}
			add_character_flag = {
				flag = mourning_main_spouse_flag
				years = 1
			}
			remove_character_flag = dead_main_spouse_flag
		}
		
		hidden_effect = {
			if = {
				limit = {
					any_courtier = {
						OR = {	
							is_close_or_extended_family_of = root
							is_councillor_of = root
							is_knight = yes
							is_consort_of = root
						}
						OR = {	
							is_imprisoned_by = root
							is_imprisoned = no
						}
						NOT = {
							has_trait = incapable
						}
						is_betrothed = no
						age >=14
						count >= 1
					}
				}
				every_courtier = {
					limit = {	
						OR = {	
							is_close_or_extended_family_of = root
							is_councillor_of = root
							is_knight = yes
							is_consort_of = root
						}
						OR = {	
							is_imprisoned_by = root
							is_imprisoned = no
						}
						NOT = {
							has_trait = incapable
						}
						OR = {	
							is_betrothed = no
							AND = {	
								is_betrothed = yes
								OR = {	
									age = 14
									betrothed = {
										age <= 14
									}
								}
							}
						}
						age >= 14
					}
					add_character_modifier = {
						modifier = mourner_modifier
						years = 1
					}
					if = {
						limit = {
							has_character_modifier = merry_mourner_modifier
						}
						remove_character_modifier = merry_mourner_modifier
					}
				}
			}
		}
		
		stress_impact = {
			cynical = miniscule_stress_impact_gain
			lustful = miniscule_stress_impact_gain
			disloyal = miniscule_stress_impact_gain
		}
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = 0.10
				ai_energy = 0.15
				ai_rationality = 0.10
   			}
			modifier = {
				add = -25
				any_ally = {
					count = 0
				}
			}
			modifier = {
				add = 10
				has_character_flag = dead_important_relative_flag
			}
			modifier = {
				add = 10
				has_character_flag = dead_main_spouse_flag
			}
			modifier = {
				add = -25
				has_trait = cynical
			}
			modifier = {
				add = -25
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = disloyal
			}
			modifier = {
				add = 20
				has_trait = zealous
			}
			modifier = {
				add = 10
				has_trait = compassionate
			}
			modifier = {
				add = 10
				has_trait = forgiving
			}
			modifier = { #Ancestors
				add = 20
				any_parent = {
					this = scope:dead_relation
				}
				OR = {
					faith = { has_doctrine = tenet_ancestor_worship }
					culture = { has_cultural_tradition = tradition_mystical_ancestors }
				}
			}
        }
    }
	
	option = { # Whatever
        name = harem_politics.0015.b
		flavor = harem_politics.0015.b_tt
		
		if = {
			limit = {
				OR = {
					has_character_flag = dead_important_relative_flag
					has_character_flag = dead_main_spouse_flag
				}
			}
			add_character_modifier = {
				modifier = merry_mourner_modifier
				years = 1
			}
			if = {
				limit = {
					is_valid_for_legitimacy_change = yes
				}
				add_legitimacy = medium_legitimacy_loss
			}
			if = {
				limit = {
					any_parent = {
						this = scope:dead_relation
					}
					OR = {
						faith = { has_doctrine = tenet_ancestor_worship }
						culture = { has_cultural_tradition = tradition_mystical_ancestors }
					}
				}
				add_character_modifier = {
					modifier = unfilial_opinion_modifier
					years = 10
				}
			}
		}
		else = {
			add_piety = miniscule_piety_loss
		}
		
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
        ai_chance = {
            base = 20
            ai_value_modifier = {
				ai_honor = -0.10
				ai_energy = -0.15
				ai_rationality = -0.10
   			}
			modifier = {
				add = 25
				any_ally = {
					count = 0
				}
			}
			modifier = {
				add = 10
				has_trait = callous
			}
			modifier = {
				add = 10
				has_trait = sadistic
			}
			modifier = {
				add = 15
				has_trait = cynical
			}
			modifier = {
				add = 15
				has_trait = lustful
			}
			modifier = {
				add = 10
				has_trait = disloyal
			}
			modifier = {
				add = -25
				has_trait = zealous
			}
			modifier = {
				add = -25
				has_trait = compassionate
			}
			modifier = {
				add = -25
				has_trait = forgiving
			}
			modifier = {
				add = 15
				is_at_war = yes
			}
			modifier = { #Less likely if low legitimacy
				add = -35
				OR = {
					AND = {
						highest_held_title_tier = tier_empire
						legitimacy_level <= 3
					}
					AND = {
						highest_held_title_tier = tier_kingdom
						legitimacy_level <= 2
					}
					AND = {
						highest_held_title_tier = tier_duchy
						legitimacy_level <= 1
					}
				}
				OR = {
					has_character_flag = dead_important_relative_flag
					has_character_flag = dead_main_spouse_flag
				}
			}
        }
    }
}

##################################
##Your concubines are performing##
##################################
scripted_trigger harem_politics_valid_harem_head_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_knight = no

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_forgotten_consort_trigger = no
	
	is_head_of_the_harem_trigger = {
		LIEGE = root
	}
	
	NOR = {
		has_trait = ill
		has_trait = wounded
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_valid_performer_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_knight = no

	harem_politics_punished_consort_trigger = no
	
	has_character_flag = flag_new_consort
	age <= 23

	NOR = {
		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic

		has_trait = clubfooted
		has_trait = hunchbacked
		has_trait = wheezing
		has_trait = spindly
		has_trait = one_eyed
		has_trait = one_legged
		has_trait = disfigured

		has_trait = wounded

		has_trait = infirm
		has_trait = incapable

		has_trait = maimed
		has_trait = blind
		has_trait = ill
		has_trait = bubonic_plague
		has_trait = cancer
		has_trait = consumption
		has_trait = great_pox
		has_trait = gout_ridden
		has_trait = leper
		has_trait = lovers_pox
		has_trait = pneumonic
		has_trait = smallpox
		has_trait = typhus
		has_trait = physique_bad_3
		
		has_trait = dysentery
		has_trait = ergotism
		has_trait = measles

		has_trait = pregnant

	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0016 = {
	type = character_event
	title = harem_politics.0016.t
	desc = {
		desc = harem_politics.0016.first.desc
		first_valid = {
			triggered_desc = { #Good performers
				trigger = {
					any_in_list = {
						list = performers_list
						diplomacy >= high_skill_rating
						count >= 2
					}
				}
				desc = harem_politics.0016.good.desc
			}
			triggered_desc = { #Decent performers
				trigger = {
					any_in_list = {
						list = performers_list
						diplomacy >= medium_skill_rating
						count >= 2
					}
				}
				desc = harem_politics.0016.decent.desc
			}
			triggered_desc = { #Bad performers
				desc = harem_politics.0016.bad.desc
			}
		}
		desc = harem_politics.0016.end.desc
	}
	theme = family
	override_background = {
		reference = garden
	}
	
	right_portrait  = {
		character = root
		animation = happiness
	}
	left_portrait = {
		character = scope:harem_head
		animation = flirtation_left
	}
	lower_left_portrait = {
		character = scope:performer_1
	}
	lower_center_portrait = {
		character = scope:performer_2
	}
	lower_right_portrait = {
		character = scope:performer_3
	}
	
	trigger = {
		any_courtier = {
			harem_politics_valid_harem_head_trigger = yes
			save_temporary_scope_as = temporary_harem_head
		}
		any_concubine = {
			harem_politics_valid_performer_trigger = yes
			NOT = {
				this = scope:temporary_harem_head
			}
			count >= 3
		}
		NOR = {
			has_trait = eunuch
			has_trait = celibate
			has_character_flag = flag_performing_consorts_event
			has_character_modifier = mourner_modifier
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.10
			has_royal_court = yes
			has_court_type = court_diplomatic
		}
		modifier = {
			add = 0.15
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			add = 0.10
			has_trait = lustful
		}
		modifier = {
			add = 0.10
			has_trait = deviant
		}
		modifier = {
			add = 0.10
			has_trait = rakish
		}
		modifier = {
			add = -0.25
			has_trait = shy
		}
		modifier = {
			add = -0.25
			has_trait = chaste
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		save_scope_as = actor
		if = {
			limit = {
				any_courtier = {
					harem_politics_valid_harem_head_trigger = yes
					count > 1	
				}
			}
			random_courtier = {
				limit = {
					harem_politics_valid_harem_head_trigger = yes
				}
				weight = {
					base = 1
					modifier = {
						add = head_of_the_harem_score_value
					}
				}
				save_scope_as = harem_head
			}
		}
		else = {
			random_courtier = {
				limit = {
					harem_politics_valid_harem_head_trigger = yes
				}
				save_scope_as = harem_head
			}
		}
		
		every_concubine = {
			limit = {	
				harem_politics_valid_performer_trigger = yes
				NOT = {
					this = scope:harem_head
				}
			}
			add_to_list = performers_list
		}
		hidden_effect = {
			while = {
				count = 3
				random_in_list = {
					list = performers_list
					weight = {
						base = 10
						compare_modifier = { #High diplomacy is required
							value = diplomacy
							multiplier = 1
						}
						modifier = { #Beauty
							has_trait = beauty_good_3
							add = 20
						}
						modifier = { #Beauty
							has_trait = beauty_good_2
							add = 15
						}
						modifier = { #Beauty
							has_trait = beauty_good_1
							add = 10
						}
						modifier = { #Grand Consort
							has_court_position = grand_consort_court_position
							add = 10
						}
						modifier = { #Favorites
							has_character_modifier = favored_consort_modifier
							add = 10
						}
						modifier = { #Favorites
							has_character_modifier = beloved_consort_modifier
							add = 15
						}
						modifier = { #Influential consort
							any_close_or_extended_family_member = {
								OR = {
									is_powerful_vassal_of = root
									is_councillor_of = root
									is_liege_or_above_of = root
									AND = {
										is_knight_of = root
										is_acclaimed = yes
									}
								}
							}
							add = 10
						}
					}
					if = {
						limit = {
							NOT = {
								exists = scope:performer_1
							}
						}
						save_scope_as = performer_1
					}
					else_if = {
						limit = {
							NOT = {
								exists = scope:performer_2
							}
						}
						save_scope_as = performer_2
					}
					else = {
						save_scope_as = performer_3
					}
					remove_from_list = performers_list
				}
			}
		}
	}
	
	option = { # Sleep with first performer
        name = harem_politics.0016.a
		
		scope:performer_1 = {
			save_scope_as = chosen_consort
		}
		scope:performer_2 = {
			save_scope_as = rejected_1
		}
		scope:performer_3 = {
			save_scope_as = rejected_2
		}
		if = {
			limit = {
				scope:harem_head = {
					is_consort_of = root
				}
			}
			scope:harem_head = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:performer_1
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_1
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
            	add = 10
            	scope:performer_1 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:performer_1 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:performer_1 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }

			modifier = {
            	add = -10
            	scope:performer_1 = {
            		has_character_modifier = unfavored_consort_modifier
            	}
            }
			modifier = {
            	add = -25
            	scope:performer_1 = {
            		has_character_modifier = forgotten_consort_modifier
            	}
            }

			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:performer_1
					has_relation_soulmate = scope:performer_1
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:performer_1
					has_relation_friend = scope:performer_1
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_1
			}
			modifier = {	
				add = -35
				NOT = {
					is_attracted_to_gender_of = scope:performer_1
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
			
			compare_modifier = { #High diplomacy
				value = scope:performer_1.diplomacy
				multiplier = 0.8
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_1 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:performer_1 = { 
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
							AND = {
								is_knight_of = root
								is_acclaimed = yes
							}
						}
					}
				}
				add = 5
			}
        }
    }
	
	option = { # Sleep with second performer
        name = harem_politics.0016.b
		
		scope:performer_1 = {
			save_scope_as = rejected_1
		}
		scope:performer_2 = {
			save_scope_as = chosen_consort
		}
		scope:performer_3 = {
			save_scope_as = rejected_2
		}
		if = {
			limit = {
				scope:harem_head = {
					is_consort_of = root
				}
			}
			scope:harem_head = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:performer_2
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_2
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
            	add = 10
            	scope:performer_2 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:performer_2 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:performer_2 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }

			modifier = {
            	add = -10
            	scope:performer_2 = {
            		has_character_modifier = unfavored_consort_modifier
            	}
            }
			modifier = {
            	add = -25
            	scope:performer_2 = {
            		has_character_modifier = forgotten_consort_modifier
            	}
            }

			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:performer_2
					has_relation_soulmate = scope:performer_2
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:performer_2
					has_relation_friend = scope:performer_2
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_2
			}
			modifier = {	
				add = -35
				NOT = {
					is_attracted_to_gender_of = scope:performer_2
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
			
			compare_modifier = { #High diplomacy
				value = scope:performer_2.diplomacy
				multiplier = 0.8
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_2 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:performer_2 = { 
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
							AND = {
								is_knight_of = root
								is_acclaimed = yes
							}
						}
					}
				}
				add = 5
			}
        }
    }
	
	option = { # Sleep with third performer
        name = harem_politics.0016.c
		
		scope:performer_1 = {
			save_scope_as = rejected_1
		}
		scope:performer_2 = {
			save_scope_as = rejected_2
		}
		scope:performer_3 = {
			save_scope_as = chosen_consort
		}
		if = {
			limit = {
				scope:harem_head = {
					is_consort_of = root
				}
			}
			scope:harem_head = {
				save_scope_as = rejected_3
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:performer_3
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_3
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
            	add = 10
            	scope:performer_3 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:performer_3 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:performer_3 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }

			modifier = {
            	add = -10
            	scope:performer_3 = {
            		has_character_modifier = unfavored_consort_modifier
            	}
            }
			modifier = {
            	add = -25
            	scope:performer_3 = {
            		has_character_modifier = forgotten_consort_modifier
            	}
            }

			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:performer_3
					has_relation_soulmate = scope:performer_3
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:performer_3
					has_relation_friend = scope:performer_3
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_3
			}
			modifier = {	
				add = -35
				NOT = {
					is_attracted_to_gender_of = scope:performer_3
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
			
			compare_modifier = { #High diplomacy
				value = scope:performer_3.diplomacy
				multiplier = 0.8
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_3 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:performer_3 = { 
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
							AND = {
								is_knight_of = root
								is_acclaimed = yes
							}
						}
					}
				}
				add = 5
			}
        }
    }
	
	option = { # Sleep with harem head
        name = harem_politics.0016.d
		trigger = {
			scope:harem_head = {
				is_consort_of = root
				NOT = {
					has_trait = pregnant
				}
			}
		}
		
		scope:performer_1 = {
			save_scope_as = rejected_1
		}
		scope:performer_2 = {
			save_scope_as = rejected_2
		}
		scope:performer_3 = {
			save_scope_as = rejected_3
		}
		if = {
			limit = {
				scope:harem_head = {
					is_consort_of = root
				}
			}
			scope:harem_head = {
				save_scope_as = chosen_consort
			}
		}
		chosen_consort_effect = yes
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			opinion_modifier = {
				opinion_target = scope:harem_head
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:harem_head
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
            	add = 10
            	scope:harem_head = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:harem_head = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:harem_head = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }

			modifier = {
            	add = -10
            	scope:harem_head = {
            		has_character_modifier = unfavored_consort_modifier
            	}
            }

			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:harem_head
					has_relation_soulmate = scope:harem_head
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:harem_head
					has_relation_friend = scope:harem_head
            	}
            }
            modifier = {	#Weight down for stress.
				add = 15
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:harem_head
			}
			modifier = {	
				add = -35
				NOT = {
					is_attracted_to_gender_of = scope:harem_head
				}
			}
			modifier = {
				add = 15
				any_child = {
					count <= 1
				}
			}
			
			compare_modifier = { #High diplomacy
				value = scope:harem_head.diplomacy
				multiplier = 0.8
			}
			modifier = { #Beauty
				scope:harem_head = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:harem_head = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:harem_head = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:harem_head = { 
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
							AND = {
								is_knight_of = root
								is_acclaimed = yes
							}
						}
					}
				}
				add = 5
			}
        }
    }
	
	option = { # Enjoy the performance
        name = harem_politics.0016.e
		if = {
			limit = {
				NOR = {
					has_trait = shy
					has_trait = chaste
					has_trait = lustful
					has_trait = rakish
					has_trait = deviant
				}
			}
			stress_impact = { base = minor_stress_impact_loss }
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			rakish = minor_stress_impact_gain
			deviant = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = -0.20
				ai_energy = -0.35
   			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = deviant
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -10
				has_trait = shy
			}
        }
    }
	
	option = { # Seclude yourself
        name = harem_politics.0016.f
		trait = reclusive
		trait = shy
		trait = chaste
		trigger = {
			OR = {
				has_trait = reclusive
				has_trait = shy
				has_trait = chaste
			}
		}
		
		hidden_effect = {
			scope:performer_1 = {
				if = {
					limit = {
						opinion = {
							target = root
							value >= 10
						}
					}	
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -5
					}
				}
			}
			scope:performer_2 = {
				if = {
					limit = {
						opinion = {
							target = root
							value >= 10
						}
					}	
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -5
					}
				}
			}
			scope:performer_3 = {
				if = {
					limit = {
						opinion = {
							target = root
							value >= 10
						}
					}	
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -5
					}
				}
			}
			scope:harem_head = {
				if = {
					limit = {
						opinion = {
							target = root
							value >= 10
						}
					}	
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -5
					}
				}
			}
		}
		
		add_prestige = medium_prestige_loss
		stress_impact = {
			reclusive = minor_stress_impact_loss
			shy = minor_stress_impact_loss
			chaste = minor_stress_impact_loss
			
			brave = minor_stress_impact_gain
			lustful = minor_stress_impact_gain
			rakish = minor_stress_impact_gain
			deviant = minor_stress_impact_gain
		}
        ai_chance = {
            base = 100
			modifier = {	#Tribal rulers value their prestige the most
				add = -15
				government_has_flag = government_is_tribal
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = brave
			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = rakish
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = deviant
			}
			modifier = {	#Weight up for stress.
				add = 50
				has_trait = chaste
			}
			modifier = {	#Weight up for stress.
				add = 50
				has_trait = shy
			}
			modifier = {	#Weight up for stress.
				add = 80
				has_trait = reclusive
			}
        }
    }
	after = {
		add_character_flag = {
			flag = flag_performing_consorts_event
			years = 4
		}
		add_character_flag = flag_had_performing_consorts_event
	}
}

########################
##Meeting Consort Ling##
########################

##She's a maid##
harem_politics.0017 = {
	type = character_event
	title = harem_politics.0009.t
	desc = {
		desc = harem_politics.0017.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:yanwan = {
						is_male = yes
					}
				}
				desc = harem_politics.0017.seamster.desc
			}
			triggered_desc = {
				desc = harem_politics.0017.seamstress.desc
			}
		}
		desc = harem_politics.0017.end.desc
	}
	theme = seduce_scheme
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = root
		animation = personality_rational
	}
	right_portrait = {
		character = scope:yanwan
		animation = flirtation
	}
	
	trigger = {
		NOR = {
        	any_consort = {
	        	has_character_flag = flag_yanwan
	        }
			has_character_flag = met_yanwan_maid_flag
			has_character_modifier = mourner_modifier
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
	    }
		allowed_more_concubines = yes
		is_available_healthy_adult = yes
		is_available_at_peace_adult = yes
		highest_held_title_tier >= tier_kingdom
		trigger_if = {
			limit = {
				has_ep1_dlc_trigger = yes
			}
			trigger_if = {
				limit = {
					NOT = {
						government_has_flag = government_is_tribal
					}
				}
				has_royal_court = yes
				amenity_level = {
					type = court_servants
					value >= 3
				}
			}
			trigger_else = {
				government_has_flag = government_is_tribal
			}
		}
		trigger_else = {
			has_ep1_dlc_trigger = no
		}
		any_consort = {
			is_courtier_of = root
			count >= 3
		}
		OR = {
			has_character_flag = met_yanwan_chun_fei
			has_character_flag = met_yanwan_jia_fei
		}
		harem_politics_valid_event_county_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = chaste
		}
		modifier = {
			add = 0.2
			has_trait = lustful
		}
		modifier = {
			add = 0.2
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.4
			age >= 45
		}
		modifier = {
			number_of_concubines < number_of_desired_concubines
			add = 0.1
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.2
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		#Create Yanwan
		create_yanwan_effect = yes
	}
	
	option = { #Take Yanwan as a concubine
        name = harem_politics.0017.a
		trigger = {
			allowed_more_concubines = yes
		}

		take_special_concubine_event_effect = {
			RECIPIENT = scope:yanwan
			FLAG = yanwan
		}
		had_sex_with_effect = {
			CHARACTER = scope:yanwan
			PREGNANCY_CHANCE = pregnancy_chance
		}
		hidden_effect = {
			every_consort = {
				limit = {
					NOR = {
						this = scope:yanwan
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					harem_politics_evil_consort_trigger = yes
					OR = {
						hp_accepts_concubinage = yes
						hp_accepts_polygamy = yes
					}
					opinion = {
						target = root
						value >= -15
					}
					is_courtier_of = root
				}
				add_opinion = {
					target = scope:yanwan
					modifier = jealousy_opinion
					opinion = -10
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain 
			arrogant = minor_stress_impact_gain 
			paranoid = minor_stress_impact_gain 
			shy = minor_stress_impact_gain 
			craven = minor_stress_impact_gain 
		}
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_rationality = -0.1
				ai_honor = -0.15
				ai_boldness = 0.1
				ai_greed = 0.1
				ai_sociability = 0.2
			}
			opinion_modifier = {
				opinion_target = scope:yanwan
				multiplier = 0.5
			}
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:yanwan
				min = -20
				max = 20
				multiplier = 2
			}

			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

            modifier = {	#Weight down for stress.
				add = 20
				has_trait = lustful
			}
			modifier = {
				add = 10
				has_trait = greedy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = craven
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = shy
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:yanwan } }
				factor = 0
			}
        }
    }
	
	option = { # Ignore her
        name = harem_politics.0017.b
		hidden_effect = {
			scope:yanwan = {
				death = {
					death_reason = death_vanished
				}
			}
		}
        stress_impact = {
        	lustful = minor_stress_impact_gain
        }
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_rationality = 0.1
				ai_honor = 0.15
				ai_boldness = -0.1
				ai_greed = -0.1
				ai_sociability = -0.3
			}
			opinion_modifier = {
				opinion_target = scope:yanwan
				multiplier = -0.5
			}
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:yanwan
				min = -20
				max = 20
				multiplier = -2
			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = arrogant
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = shy
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = craven
			}
        }
    }
	after = {
		add_character_flag = met_yanwan_maid_flag
	}
}

##She's singing in the gardens##
harem_politics.0018 = {
	type = character_event
	title = consort_events.0006.t
	desc = harem_politics.0018.desc
	theme = seduce_scheme
	override_background = {
		reference = garden
	}
	
	right_portrait = { 	
		character = scope:yanwan
		animation = flirty
	}
	left_portrait = { 	
		character = root
		animation = personality_content
	}
	
	trigger = {
		primary_spouse ?= {
			NOT = {
				this = scope:yanwan
			}
		}
		scope:yanwan = {
			is_consort_of = root
			is_courtier_of = root
			is_physically_able_adult = yes
			
			NOR = {				
				has_trait = pregnant
				has_trait = ill
				has_trait = wounded
				
				has_character_flag = flag_scolded_consort
				has_character_modifier = recently_tortured
				has_character_modifier = hunt_tasted_the_belt_modifier
				has_character_modifier = sleep_deprived_modifier
				has_character_modifier = intrigue_starved_and_deprived_modifier
			}
			
			OR = { 
				AND = {
					is_travelling = yes
					current_travel_plan = {
						travel_plan_owner = root
					}
				}
				AND = {
					is_travelling = no
					root = {
						is_travelling = no
					}
				}
			}
		}
		has_character_modifier = mourner_modifier
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		NOR = {
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
	    }
	}
	
	immediate = {
		save_scope_as = harem_liege
	}
	
	option = { #Sleep with Yanwan
        name = harem_politics.0018.a
		
		had_sex_with_effect = {
			CHARACTER = scope:yanwan
			PREGNANCY_CHANCE = pregnancy_chance
		}
		
		scope:yanwan = {
			calyver_favor_minor_gain_effect = yes
		}
		
		hidden_effect = {
			every_consort = {
				limit = {
					NOR = {
						this = scope:yanwan
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					hp_accepts_harems = yes
					opinion = {
						target = root
						value >= -10
					}
					opinion = {
						target = scope:yanwan
						value <= 5
					}
					is_courtier_of = root
				}
				add_opinion = {
					target = scope:yanwan
					modifier = insolent_consort_opinion
					opinion = -10
				}
			}
		}
		
		stress_impact = {
			chaste = minor_stress_impact_gain 
			shy = minor_stress_impact_gain 
			zealous = minor_stress_impact_gain 
			deviant = minor_stress_impact_loss 
			craven = minor_stress_impact_gain 
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = -0.10
				ai_honor = -0.1
				ai_greed = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:yanwan
				min = -40
				max = 40
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = deviant
				add = 25
			}
			modifier = { #Stress management
				has_trait = lustful
				add = 25
			}
			modifier = { #Stress management
				has_trait = rakish
				add = 25
			}
			modifier = { #Stress management
				has_trait = chaste
				add = -25
			}
			modifier = { #Stress management
				has_trait = shy
				add = -25
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = craven
			}
			modifier = { #Stress management
				has_trait = zealous
				add = -25
			}
			
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:yanwan
				min = -20
				max = 20
				multiplier = 2
			}

			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = -5
			}
			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = -10
			}
        }
    }
	
	#Torture them
	option = {
		name = harem_politics.0018.b
		
		stress_impact = {
			compassionate = miniscule_stress_impact_gain
			forgiving = miniscule_stress_impact_gain
			calm = miniscule_stress_impact_gain
			sadistic = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			wrathful = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
		}
		
		scope:yanwan = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:yanwan
				}
			}
			calyver_favor_medium_loss_effect = yes
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = root } 
				}
				set_relation_potential_rival = root
			}
			add_character_modifier = {
				modifier = hunt_tasted_the_belt_modifier
				years = 2
			}
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -20
			}
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_honor = -0.15
			}

			opinion_modifier = { #Opinion
				opinion_target = scope:yanwan
				min = -30
				max = 30
				multiplier = -1
			}
			modifier = { #Stress management
				has_trait = calm
				add = -25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = -25
			}
			modifier = { #Stress management
				has_trait = sadistic
				add = 25
			}
			modifier = { #Stress management
				has_trait = callous
				add = 25
			}
			modifier = { #Stress management
				has_trait = wrathful
				add = 25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = 25
			}
			modifier = { #Stress management
				has_trait = zealous
				add = 15
			}
			
			modifier = { #Mothers are important
				scope:yanwan = {
					any_child = {
						is_child_of = scope:partner
						count >= 1
					}
				}
				add = -15
			}
			
			modifier = { #Less if the consort is not important
				scope:yanwan = {
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = scope:partner
							is_councillor_of = scope:partner
							is_parent_of = scope:partner
							is_liege_or_above_of = scope:partner
							this = scope:partner
						}
					}
				}
				add = -15
			}

			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}
			
		}
	}
	
	#Deprive them from sleep
	option = {
		name = harem_politics.0018.c
		
		stress_impact = {
			compassionate = miniscule_stress_impact_gain
			forgiving = miniscule_stress_impact_gain
			calm = miniscule_stress_impact_gain
		}
		
		scope:yanwan = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:yanwan
				}
			}
			calyver_favor_moderate_loss_effect = yes
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = root } 
				}
				set_relation_potential_rival = root
			}
			add_character_modifier = {
				modifier = sleep_deprived_modifier
				years = 2
			}
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -20
			}
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_honor = 0.15
			}

			opinion_modifier = { #Opinion
				opinion_target = scope:yanwan
				min = -20
				max = 20
				multiplier = -1
			}
			modifier = { #Stress management
				has_trait = calm
				add = -25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = -25
			}
			modifier = { #Stress management
				has_trait = sadistic
				add = -10
			}
			modifier = { #Stress management
				has_trait = callous
				add = -10
			}
			modifier = { #Stress management
				has_trait = wrathful
				add = -10
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = -10
			}
			modifier = { #Traits
				has_trait = diligent
				add = 10
			}
			modifier = { #Traits
				has_trait = just
				add = 10
			}
			modifier = { #Traits
				has_trait = zealous
				add = 15
			}
			
			modifier = { #Mothers are important
				scope:yanwan = {
					any_child = {
						is_child_of = root
						count >= 1
					}
				}
				add = 10
			}
			
			modifier = { #Less if the consort is not important
				scope:yanwan = {
					any_close_or_extended_family_member = {
						OR = {
							is_powerful_vassal_of = scope:partner
							is_councillor_of = scope:partner
							is_parent_of = scope:partner
							is_liege_or_above_of = scope:partner
							this = scope:partner
						}
					}
				}
				add = -10
			}

			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 5
			}
			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 10
			}
		}
	}
	
	#Lecture them
	option = {
		name = consort_events.0001.c
		stress_impact = {
			sadistic = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
			vengeful = minor_stress_gain
			zealous = minor_stress_gain
		}
		scope:valid_target_consort = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				target = root
				modifier = scolded_me_opinion
				opinion = -5
			}
			add_character_flag = {
				flag = flag_scolded_consort
				years = 1
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_honor = -0.15
			}

			opinion_modifier = { #Opinion
				opinion_target = scope:yanwan
				min = -40
				max = 40
				multiplier = 1
			}
			modifier = { #Stress management
				has_trait = calm
				add = 25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = 25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = 25
			}
			modifier = { #Stress management
				has_trait = sadistic
				add = -25
			}
			modifier = { #Stress management
				has_trait = callous
				add = -25
			}
			modifier = { #Stress management
				has_trait = wrathful
				add = -25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = -25
			}
			modifier = { #Stress management
				has_trait = zealous
				add = -25
			}
			modifier = { #Traits
				has_trait = just
				add = -10
			}
			
			modifier = { #Mothers are important
				scope:yanwan = {
					any_child = {
						is_child_of = scope:partner
						count >= 1
					}
				}
				add = 15
			}

			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = unfavored_consort_modifier
				}
				add = 1
			}
			modifier = { #Favor
				scope:yanwan = {
					has_character_modifier = forgotten_consort_modifier
				}
				add = 5
			}
		}
	}
	
}

############################
##Yu disrespects Zhen Huan##
############################

scripted_trigger harem_politics_yu_daying_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_healthy = yes

	harem_politics_evil_consort_trigger = yes
	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	hp_accepts_harems = yes
	
	has_character_flag = flag_new_consort
	age <= 23
	
	any_child = {
		count = 0
	}

	NOR = {
		AND = {	
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		has_court_position = grand_consort_court_position
		
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic
		
		has_trait = beauty_bad
		
		has_trait = calm
		has_trait = craven
		has_trait = shy
		has_trait = temperate
		has_trait = humble

		has_trait = pregnant		
		has_trait = wounded
		has_trait = ill
		
		has_relation_nemesis = root
		has_relation_rival = root
		has_relation_potential_rival = root

		any_close_or_extended_family_member = {
			AND = {	
				exists = root.primary_spouse
				this = root.primary_spouse
			}
			is_powerful_vassal_of = root
			is_councillor_of = root
			is_parent_of = root
			is_liege_or_above_of = root
		}

		has_strong_hook = root

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
		has_character_modifier = unfavored_consort_modifier
		has_character_modifier = forgotten_consort_modifier
	}
	
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_wan_changzai_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_healthy = yes

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_favored_consort_trigger = no
	hp_accepts_harems = yes
	
	has_character_flag = flag_new_consort
	age <= 23
	
	any_child = {
		count = 0
	}
	
	NOR = {
		AND = {	
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		has_court_position = grand_consort_court_position

		this = $YU_DAYING$
		
		has_relation_best_friend = $YU_DAYING$
		has_relation_friend = $YU_DAYING$
		has_relation_potential_friend = $YU_DAYING$
		
		has_relation_soulmate = $YU_DAYING$
		has_relation_lover = $YU_DAYING$
		has_relation_potential_lover = $YU_DAYING$
		
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic
		
		has_trait = beauty_bad

		has_trait = pregnant		
		has_trait = wounded
		has_trait = ill

		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_potential_friend = root

		has_relation_soulmate = root
		has_relation_lover = root
		has_relation_potential_lover = root
		
		has_relation_nemesis = root
		has_relation_rival = root
		has_relation_potential_rival = root

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
	}
	
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0019 = {
	type = character_event
	title = harem_politics.0019.t
	desc = {
		desc = harem_politics.0019.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:yu_daying = {
						is_concubine = yes
					}
				}
				desc = harem_politics.0019.concubine.desc
			}
			triggered_desc = {
				desc = harem_politics.0019.spouse.desc
			}
		}
		desc = harem_politics.0019.end.desc
	}
	theme = unfriendly
	override_background = {
		reference = garden
	}
	
	right_portrait = { 	
		character = scope:zhen_huan
		animation = shock
	}
	left_portrait = { 	
		character = scope:yu_daying
		animation = rage
	}
	
	trigger = {
		any_consort = {
			count >= 4
		}
		OR = {
			AND = {
				hp_accepts_concubinage = yes
				any_concubine = {
					harem_politics_yu_daying_trigger = yes
					save_temporary_scope_as = temporary_yu_daying
				}
				any_concubine = {
					harem_politics_wan_changzai_trigger = { YU_DAYING = scope:temporary_yu_daying }
				}
			}
			AND = {
				hp_accepts_polygamy = yes
				hp_accepts_concubinage = no
				any_spouse = {
					harem_politics_yu_daying_trigger = yes
					save_temporary_scope_as = temporary_yu_daying
				}
				any_spouse = {
					harem_politics_wan_changzai_trigger = { YU_DAYING = scope:temporary_yu_daying }
				}
			}
		}
		
		NOR = {	
			has_character_modifier = mourner_modifier
			has_character_flag = had_yu_event_flag
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_balancing_favor_flag
			}
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}

	weight_multiplier = {
		base = 1
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.3
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		if = {
			limit = {
				hp_accepts_concubinage = yes
			}
			every_concubine = {
				add_to_list = consort_list
			}
		}
		else_if = {
			limit = {
				hp_accepts_polygamy = yes
				hp_accepts_concubinage = no
			}
			every_spouse = {
				add_to_list = consort_list
			}
		}
		random_in_list = { #Yu Daying
			list = consort_list
			limit = {
				harem_politics_yu_daying_trigger = yes
			}
			weight = {
				base = 10
				
				modifier = { #She was a servant
					is_lowborn = yes
					add = 10
				}

				modifier = {
					has_trait = intellect_bad
					add = 20
				}
				modifier = {
					has_trait = beauty_good
					add = 10
				}
				modifier = {
					has_trait = arrogant
					add = 20
				}
				modifier = {
					has_trait = ambitious
					add = 20
				}
				modifier = {
					has_trait = greedy
					add = 20
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 20
				}
				modifier = {
					has_character_modifier = favor_boost_modifier
					add = 25
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 30
				}
			}
			save_scope_as = yu_daying
		}
		random_in_list = { #Zhen Huan
			list = consort_list
			limit = {
				harem_politics_wan_changzai_trigger = { YU_DAYING = scope:yu_daying }
			}
			weight = {
				base = 10
				
				modifier = {
					has_character_modifier = unfavored_consort_modifier
					add = 20
				}
				modifier = {
					has_character_modifier = forgotten_consort_modifier
					add = 30
				}
				modifier = {
					OR = {	
						has_relation_potential_rival = scope:yu_daying
						has_relation_rival = scope:yu_daying
						has_relation_nemesis = scope:yu_daying
					}
					add = 15
				}
				opinion_modifier = { #Opinion
					WHO = scope:yu_daying
					opinion_target = this
					min = 0
					max = 50
					multiplier = -0.50
				}
				compatibility_modifier = {
					compatibility_target = scope:yu_daying
					multiplier = -2
					min = 1
					max = 30
				}
				
				modifier = {
					is_lowborn = no
					add = 10
				}

				modifier = {
					has_trait = intellect_good
					add = 20
				}
				modifier = {
					has_trait = beauty_good
					add = 10
				}
				modifier = {
					has_trait = humble
					add = 20
				}
				modifier = { #Zhen Huan isn't craven
					NOR = {
						has_trait = craven
						has_trait = shy
					}
					add = 20
				}
			}
			save_scope_as = zhen_huan
		}

		scope:yu_daying = {
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:zhen_huan }
				}
				set_relation_potential_rival = scope:zhen_huan
			}
			calyver_favor_minor_gain_effect = yes
			if = {
				limit = {
					has_variable = favor
				}
				change_variable = {
					name = favor
					add = 49
				}
			}
			hidden_effect = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = insolent_consort_opinion
					opinion = -10
				}
			}
		}
		scope:zhen_huan = {
			if = {
				limit = {
					NOR = {
						has_character_modifier = unfavored_consort_modifier
						has_character_modifier = forgotten_consort_modifier
					}
				}
				calyver_favor_big_loss_effect = yes
			}
			hidden_effect = {
				add_opinion = {
					target = scope:yu_daying
					modifier = insolent_consort_opinion
					opinion = -10
				}
			}
		}
	}
	
	option = { #Dismiss Yu
        name = harem_politics.0019.a
		flavor = harem_politics.0019.a_tt
		trigger = {
			scope:yu_daying = {
				is_concubine = yes
			}
		}
		save_scope_as = actor
		scope:yu_daying = {
			save_scope_as = recipient
			
			#Yu becomes rivals with Zhen Huan
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:zhen_huan }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:zhen_huan
				}
			}
		}
		#Dismissing Yu
		calyver_dismiss_concubine_effect = yes
		
		scope:zhen_huan = {
			calyver_favor_huge_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			if = {
				limit = {
					NOT = {
						has_relation_soulmate = root
						has_relation_lover = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
		}
		
		
		
		stress_impact = {
			calm = minor_stress_impact_gain
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_honor = 0.1
				ai_greed = -0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -40
				max = 40
				multiplier = 1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:yu_daying
				min = -40
				max = 40
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = calm
				add = -25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = -25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = 15
			}
			modifier = { #Stress management
				has_trait = just
				add = 15
			}
			
			modifier = { #Harem size
				number_of_concubines <= number_of_desired_concubines
				add = -10
			}

			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}
			
        }
    }
	
	option = { #Divorce Yu
		name = harem_politics.0019.b
		flavor = harem_politics.0019.b_tt
		trigger = {
			scope:yu_daying = {
				is_spouse_of = root
			}
			faith = {
				# We are not required to seek approval of a spiritual HoF
				NAND = {
					has_doctrine = doctrine_divorce_approval
					has_doctrine = doctrine_spiritual_head
					exists = religious_head
				}
				# We are not required to seek approval of a house head
				NAND = {
					has_doctrine = doctrine_divorce_approval
					exists = root.house
					exists = root.house.house_head
					root = { is_house_head = no }
				}
			}
			NOR = {
				culture = {
					has_cultural_parameter = cannot_divorce
				}
				faith = {
					has_doctrine = doctrine_divorce_disallowed
				}
			}
		}
		save_scope_as = actor
		scope:yu_daying = {
			save_scope_as = recipient
		}
		#Divorcing Yu
		divorce_effect = {
			DIVORCER = scope:actor
			DIVORCEE = scope:recipient
		}
		scope:recipient = {
			trigger_event = marriage_interaction.0030
			#Yu becomes rivals with Zhen Huan
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:zhen_huan }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:zhen_huan
				}
			}
		}
		scope:zhen_huan = {
			calyver_favor_huge_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			if = {
				limit = {
					NOT = {
						has_relation_soulmate = root
						has_relation_lover = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
		}
		
		stress_impact = {
			calm = minor_stress_impact_gain
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_honor = 0.1
				ai_greed = -0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -40
				max = 40
				multiplier = 1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:yu_daying
				min = -40
				max = 40
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = calm
				add = -25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = -25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = 15
			}
			modifier = { #Stress management
				has_trait = just
				add = 25
			}

			modifier = { #Harem size
				primary_title.tier >= 5
				any_spouse = {
					count = 4
				}
				add = -10
			}

			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}		
        }
	}
	
	#To the dungeon with Yu
	option = {
		name = harem_politics.0019.c
		
		imprison = {
			target = scope:yu_daying
			type = house_arrest
		}
		
		scope:yu_daying = {
			#Favor effect
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:yu_daying
				}
			}
			calyver_favor_big_loss_effect = yes
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -15
			}
			#Yu becomes rivals with Zhen Huan
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = scope:zhen_huan }
				}
				set_relation_rival = { 
					reason = consort_rival_reason
					target = scope:zhen_huan
				}
			}
		}
		
		scope:zhen_huan = {
			#Favor effect
			calyver_favor_huge_gain_effect = yes
			
			if = {
				limit = {
					NOR = {
						has_trait = compassionate
						has_trait = forgiving
					}
				}
				add_opinion = {
					target = root
					modifier = thankful_consort_opinion
				}
				if = {
					limit = {
						NOT = {
							has_relation_soulmate = root
							has_relation_lover = root
							has_relation_potential_lover = root
						}
					}
					set_relation_potential_lover = root
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -10
				}
			}
		}
		
		
		
		stress_impact = {
			forgiving = minor_stress_impact_gain 
			compassionate = minor_stress_impact_gain 
			calm = minor_stress_impact_gain
		}
		
		ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_honor = 0.1
				ai_greed = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -40
				max = 40
				multiplier = 1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:yu_daying
				min = -40
				max = 40
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = forgiving
				add = -25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = -25
			}
			modifier = { #Stress management
				has_trait = calm
				add = -25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = 15
			}
			modifier = { #Stress management
				has_trait = just
				add = 25
			}
			modifier = { #Stress management
				has_trait = callous
				add = 10
			}
			modifier = { #Stress management
				has_trait = sadistic
				add = 10
			}
			
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}
        }
	}
	
	#Lecture them
	option = {
		name = consort_events.0001.c
		stress_impact = {
			vengeful = minor_stress_gain
		}
		scope:yu_daying = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				target = root
				modifier = scolded_me_opinion
				opinion = -5
			}
			add_character_flag = {
			flag = flag_scolded_consort
				years = 1
			}
			hidden_effect = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = unfriendly_opinion
					opinion = -10
				}
			}
		}
		
		scope:zhen_huan = {
			#Favor effects
			calyver_favor_minor_gain_effect = yes
			
			#Opinion gains/losses
			if = {
				limit = {
					harem_politics_evil_consort_trigger = yes
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 5
				}
			}
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_honor = -0.15
			}

			opinion_modifier = { #Opinion
				opinion_target = scope:yu_daying
				min = -20
				max = 20
				multiplier = 1
			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -20
				max = 20
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = calm
				add = 25
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = 25
			}
			modifier = { #Stress management
				has_trait = compassionate
				add = 25
			}
			modifier = { #Stress management
				has_trait = sadistic
				add = -25
			}
			modifier = { #Stress management
				has_trait = callous
				add = -25
			}
			modifier = { #Stress management
				has_trait = wrathful
				add = -25
			}
			modifier = { #Stress management
				has_trait = vengeful
				add = -25
			}
			modifier = { #Stress management
				has_trait = zealous
				add = -25
			}
			modifier = { #Traits
				has_trait = just
				add = -10
			}
			
			modifier = { #Mothers are important
				scope:yu_daying = {
					any_child = {
						is_child_of = scope:partner
						count >= 1
					}
				}
				add = 15
			}

			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
		}
	}
	
	#Yu is right
	option = {
		name = harem_politics.0019.f
		
		stress_impact = {
			humble = minor_stress_impact_gain
			just = minor_stress_impact_gain
		}
		scope:zhen_huan = {
			#Favor effects
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:zhen_huan
				}
			}
			calyver_favor_moderate_loss_effect = yes
			#Opinion
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
		}
		
		scope:yu_daying = {
			#Favor effects
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			
			if = {
				limit = {
					NOR = {
						has_relation_soulmate = root
						has_relation_lover = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
		}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_honor = -0.15
			}

			opinion_modifier = { #Opinion
				opinion_target = scope:yu_daying
				min = -30
				max = 30
				multiplier = 1
			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -30
				max = 30
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = humble
				add = -25
			}
			
			modifier = { #Traits
				has_trait = just
				add = -25
			}

			modifier = { #Traits
				has_trait = arrogant
				add = 20
			}
			
			modifier = { #Mothers are important
				scope:yu_daying = {
					any_child = {
						is_child_of = scope:partner
						count >= 1
					}
				}
				add = 15
			}

			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:yu_daying = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
		}
	}
	
	after = {
		add_character_flag = {
			flag = had_yu_event_flag
			years = 10
		}
	}
}

################################
##Two consorts are hanging out##
################################

scripted_trigger harem_politics_walking_consort_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_healthy = yes

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	hp_accepts_harems = yes

	NOR = {
		
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic

		has_trait = shy

		has_trait = pregnant		
		has_trait = wounded
		has_trait = ill
		
		has_relation_nemesis = root
		has_relation_rival = root
		has_relation_potential_rival = root
	}
	
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_effect harem_politics_consort_scope_effect = {
	random_in_list = {
		list = consort_list
		limit = {
			harem_politics_walking_consort_trigger = yes
		}
		weight = {
			base = 10
			
			modifier = { #New consorts have priority
				has_character_flag = flag_new_consort
				add = 25
			}
			
			modifier = { #Beautiful consorts have priority
				has_trait = beauty_good_1
				add = 10
			}
			modifier = { #Beautiful consorts have priority
				has_trait = beauty_good_2
				add = 15
			}
			modifier = { #Beautiful consorts have priority
				has_trait = beauty_good_3
				add = 20
			}

			modifier = {
				has_character_modifier = favored_consort_modifier
				add = 15
			}
			modifier = {
				has_character_modifier = favor_boost_modifier
				add = 20
			}
			modifier = {
				has_character_modifier = beloved_consort_modifier
				add = 25
			}
			modifier = {
				OR = {
					has_relation_potential_friend = root
					has_relation_potential_lover = root
				}
				add = 10
			}
			modifier = {
				OR = {
					has_relation_lover = root
					has_relation_friend = root
				}
				add = 15
			}
			modifier = {
				OR = {
					has_relation_soulmate = root
					has_relation_best_friend = root
				}
				add = 20
			}
		}
		if = {
			limit = {
				NOT = {
					exists = scope:first_consort
				}
			}
			save_scope_as = first_consort
			scope:first_consort = {
				remove_from_list = consort_list
			}
		}
		else = {
			save_scope_as = second_consort
		}
	}
}

harem_politics.0020 = {
	type = character_event
	title = harem_politics.0016.t
	desc = harem_politics.0020.desc
	theme = family
	override_background = {
		reference = garden
	}
	
	right_portrait = { 	
		character = scope:first_consort
		animation = laugh
	}
	left_portrait = { 	
		character = scope:second_consort
		animation = happiness
	}
	
	trigger = {
		any_consort = {
			count >= 3
		}
		any_consort = {
			harem_politics_walking_consort_trigger = yes
			count >= 2
		}
		
		NOR = {	
			has_character_modifier = mourner_modifier
			has_character_flag = had_walking_consorts_event_flag
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.2
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			add = -0.3
			has_trait = chaste
		}
		modifier = {
			add = 0.1
			has_trait = lustful
		}
		modifier = {
			add = 0.1
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.3
			age >= 45
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				harem_politics_walking_consort_trigger = yes
			}
			add_to_list = consort_list
		}
		
		
		harem_politics_consort_scope_effect = yes
		harem_politics_consort_scope_effect = yes

		hidden_effect = {
			random = {
				chance = 100
				random_list = {
					5 = { # They were friendly
						modifier = { #Good consorts
							scope:first_consort = {
								harem_politics_evil_consort_trigger = no
							}
							add = 1
						}
						modifier = { #Good consorts
							scope:second_consort = {
								harem_politics_evil_consort_trigger = no
							}
							add = 1
						}
						modifier = { #Gregarious consorts
							scope:first_consort = {
								has_trait = gregarious
							}
							add = 2
						}
						modifier = { #Gregarious consorts
							scope:second_consort = {
								has_trait = gregarious
							}
							add = 2
						}
						modifier = { #Calm consorts
							scope:first_consort = {
								has_trait = calm
							}
							add = 1
						}
						modifier = { #Gregarious consorts
							scope:second_consort = {
								has_trait = calm
							}
							add = 1
						}
						modifier = { #Diplomatic consorts
							scope:first_consort = {
								has_character_modifier = diplomatic_consort_modifier
							}
							add = 1
						}
						modifier = { #Diplomatic consorts
							scope:second_consort = {
								has_character_modifier = diplomatic_consort_modifier
							}
							add = 1
						}
						modifier = { #Compatible consorts
							scope:first_consort = {
								trait_compatibility = {
									target = scope:second_consort
									value >= medium_positive_trait_compatibility
								}
							}
							add = 2
						}
						modifier = { #Friends
							scope:first_consort = {
								OR = {
									has_relation_potential_friend = scope:second_consort
									has_relation_friend = scope:second_consort
									has_relation_best_friend = scope:second_consort
								}
							}
							add = 2
						}
						opinion_modifier = {
							who = scope:first_consort
							opinion_target = scope:second_consort
							multiplier = 0.10
						}
						opinion_modifier = {
							who = scope:second_consort
							opinion_target = scope:first_consort
							multiplier = 0.10
						}
						
						#The GC
						#High aptitude
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 3
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 0.2
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 4
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 0.25
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 5
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 0.25
						}
						#Low aptitude
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position <= 2
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -0.25
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 1
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -0.25
						}
						
						scope:first_consort = {
							if = {
								limit = {
									can_set_relation_potential_friend_trigger = { CHARACTER = scope:second_consort }
								}
								set_relation_potential_friend = scope:second_consort
							}
							add_opinion = {
								target = scope:second_consort
								modifier = friendliness_opinion
								opinion = 5
							}
						}
						scope:second_consort = {
							add_opinion = {
								target = scope:first_consort
								modifier = friendliness_opinion
								opinion = 5
							}
						}
					}
					5 = { # They were catty
						modifier = { #Good consorts
							scope:first_consort = {
								harem_politics_evil_consort_trigger = yes
							}
							add = 1
						}
						modifier = { #Good consorts
							scope:second_consort = {
								harem_politics_evil_consort_trigger = yes
							}
							add = 1
						}
						modifier = { #Arrogant consorts
							scope:first_consort = {
								has_trait = arrogant
							}
							add = 2
						}
						modifier = { #Arrogant consorts
							scope:second_consort = {
								has_trait = arrogant
							}
							add = 2
						}
						modifier = { #Wrathful consorts
							scope:first_consort = {
								has_trait = wrathful
							}
							add = 1
						}
						modifier = { #Wrathful consorts
							scope:second_consort = {
								has_trait = wrathful
							}
							add = 1
						}
						modifier = { #Deceitful consorts
							scope:first_consort = {
								has_trait = deceitful
							}
							add = 1
						}
						modifier = { #Deceitful consorts
							scope:second_consort = {
								has_trait = deceitful
							}
							add = 1
						}
						modifier = { #Scheming consorts
							scope:first_consort = {
								has_character_modifier = scheming_consort_modifier
							}
							add = 2
						}
						modifier = { #Scheming consorts
							scope:second_consort = {
								has_character_modifier = scheming_consort_modifier
							}
							add = 2
						}
						modifier = { #Yanwan
							OR = {
								scope:first_consort = {
									has_character_flag = flag_yanwan
								}
								scope:second_consort = {
									has_character_flag = flag_yanwan
								}
							}
							add = 2
						}
						modifier = { #Favored consorts
							OR = {
								scope:first_consort = {
									harem_politics_favored_consort_trigger = yes
								}
								scope:second_consort = {
									harem_politics_favored_consort_trigger = yes
								}
							}
							add = 2
						}
						modifier = { #Compatible consorts
							scope:first_consort = {
								trait_compatibility = {
									target = scope:second_consort
									value <= low_negative_trait_compatibility
								}
							}
							add = 2
						}
						modifier = { #Rivals
							scope:first_consort = {
								OR = {
									has_relation_potential_rival = scope:second_consort
									has_relation_rival = scope:second_consort
									has_relation_nemesis = scope:second_consort
								}
							}
							add = 2
						}
						opinion_modifier = {
							who = scope:first_consort
							opinion_target = scope:second_consort
							multiplier = -0.10
						}
						opinion_modifier = {
							who = scope:second_consort
							opinion_target = scope:first_consort
							multiplier = -0.10
						}

						#The GC
						#High aptitude
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 3
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -0.2
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position >= 4
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -0.25
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 5
									has_character_flag = gc_promoting_harmony
								}
							}
							add = -0.25
						}
						#Low aptitude
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position <= 2
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 0.25
						}
						modifier = {
							scope:harem_liege = {
								employs_court_position = grand_consort_court_position
								any_court_position_holder = {
									type = grand_consort_court_position
									aptitude:grand_consort_court_position = 1
									has_character_flag = gc_promoting_harmony
								}
							}
							add = 0.25
						}
						
						scope:first_consort = {
							if = {
								limit = {
									can_set_relation_potential_rival_trigger = { CHARACTER = scope:second_consort }
								}
								set_relation_potential_rival = scope:second_consort
							}
							add_opinion = {
								target = scope:second_consort
								modifier = unfriendly_opinion
								opinion = -10
							}
						}
						scope:second_consort = {
							add_opinion = {
								target = scope:first_consort
								modifier = unfriendly_opinion
								opinion = -10
							}
						}
					}
					1 = { # Neutral conversation
						modifier = { #Shy consorts
							scope:first_consort = {
								has_trait = shy
							}
							add = 15
						}
						modifier = { #Shy consorts
							scope:second_consort = {
								has_trait = shy
							}
							add = 15
						}
						modifier = { #Craven consorts
							scope:first_consort = {
								has_trait = craven
							}
							add = 15
						}
						modifier = { #Craven consorts
							scope:second_consort = {
								has_trait = craven
							}
							add = 15
						}
						
					}
				}
			}
		}
		
	}
	
	option = { #Spend time with first consort
        name = harem_politics.0020.a

		random_list = {
			50 = { #Progress towards lovers
				simple_attraction_modifier = {
					WHO = scope:first_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:first_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:first_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					NOT = { scope:first_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:first_consort }
					factor = 0
				}
				if = {
					limit = {
						NOR = {
							has_relation_lover = scope:first_consort
							has_relation_soulmate = scope:first_consort
							has_relation_potential_lover = scope:first_consort
						}
					}
					set_relation_potential_lover = scope:first_consort
				}
				scope:first_consort = {
					calyver_favor_minor_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:first_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Sleep with them
				simple_attraction_modifier = {
					WHO = scope:first_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:first_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:first_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					OR = {
						has_relation_lover = scope:first_consort
						has_relation_soulmate = scope:first_consort
						has_relation_potential_lover = scope:first_consort
					}
					add = 15
				}
				modifier = {
					NOT = { scope:first_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:first_consort }
					factor = 0
				}
				had_sex_with_effect = {
					CHARACTER = scope:first_consort
					PREGNANCY_CHANCE = pregnancy_chance
				}
				if = {
					limit = {
						NOR = {
							has_relation_lover = scope:first_consort
							has_relation_soulmate = scope:first_consort
							has_relation_potential_lover = scope:first_consort
						}
					}
					set_relation_potential_lover = scope:first_consort
				}
				scope:first_consort = {
					calyver_favor_moderate_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:first_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Nothing
				
			}
		}
		
		hidden_effect = {
			scope:second_consort = {
				if = {
					limit = {
						opinion = {
							target = scope:first_consort
							value <= 10
						}
						harem_politics_evil_consort_trigger = yes
						opinion = {
							target = root
							value >= -10
						}
						NOT = {
							has_opinion_modifier = {
								modifier = forced_me_concubine_marriage_opinion
								target = root
							}
						}
						hp_accepts_harems = yes
					}				
					add_opinion = {
						target = scope:first_consort
						modifier = jealousy_opinion
						opinion = -10
					}
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = scope:first_consort }
						}
						set_relation_potential_rival = scope:first_consort
					}
				}
			}
		}
		
		
		
		stress_impact = {
			shy = minor_stress_impact_gain 
			craven = minor_stress_impact_gain 
			chaste = minor_stress_impact_gain
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_greed = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:first_consort
				min = -40
				max = 40
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = shy
				add = -25
			}
			modifier = { #Stress management
				has_trait = craven
				add = -25
			}
			modifier = { #Stress management
				has_trait = chaste
				add = -25
			}	
			modifier = { #Traits
				has_trait = lustful
				add = 25
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:first_consort }
				add = -50
			}
			modifier = {
				exists = primary_spouse
				scope:first_consort = { 
					this = root.primary_spouse
				}
				add = 10
			}
			modifier = {
				scope:first_consort = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = {
				any_spouse = { 
					this = scope:first_consort
				}
				add = 5
			}

			modifier = { #Favor
				scope:first_consort = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:first_consort = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:first_consort = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}

			modifier = { #Favor
				scope:first_consort = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = -10
			}
			modifier = { #Favor
				scope:first_consort = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = -20
			}
        }
    }
	
	option = { #Spend time with second consort
        name = harem_politics.0020.b

		random_list = {
			50 = { #Progress towards lovers
				simple_attraction_modifier = {
					WHO = scope:second_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:second_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:second_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					NOT = { scope:second_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:second_consort }
					factor = 0
				}
				if = {
					limit = {
						NOR = {
							has_relation_lover = scope:second_consort
							has_relation_soulmate = scope:second_consort
							has_relation_potential_lover = scope:second_consort
						}
					}
					set_relation_potential_lover = scope:second_consort
				}
				scope:second_consort = {
					calyver_favor_minor_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:second_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Sleep with them
				simple_attraction_modifier = {
					WHO = scope:second_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:second_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:second_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					OR = {
						has_relation_lover = scope:second_consort
						has_relation_soulmate = scope:second_consort
						has_relation_potential_lover = scope:second_consort
					}
					add = 15
				}
				modifier = {
					NOT = { scope:second_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:second_consort }
					factor = 0
				}
				had_sex_with_effect = {
					CHARACTER = scope:second_consort
					PREGNANCY_CHANCE = pregnancy_chance
				}
				if = {
					limit = {
						NOR = {
							has_relation_lover = scope:second_consort
							has_relation_soulmate = scope:second_consort
							has_relation_potential_lover = scope:second_consort
						}
					}
					set_relation_potential_lover = scope:second_consort
				}
				scope:second_consort = {
					calyver_favor_moderate_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:second_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Nothing
				
			}
		}
		
		hidden_effect = {
			scope:first_consort = {
				if = {
					limit = {
						opinion = {
							target = scope:second_consort
							value <= 10
						}
						harem_politics_evil_consort_trigger = yes
						opinion = {
							target = root
							value >= -10
						}
						NOT = {
							has_opinion_modifier = {
								modifier = forced_me_concubine_marriage_opinion
								target = root
							}
						}
						hp_accepts_harems = yes
					}				
					add_opinion = {
						target = scope:second_consort
						modifier = jealousy_opinion
						opinion = -10
					}
					if = {
						limit = {
							can_set_relation_potential_rival_trigger = { CHARACTER = scope:second_consort }
						}
						set_relation_potential_rival = scope:second_consort
					}
				}
			}
		}
		
		
		
		stress_impact = {
			shy = minor_stress_impact_gain 
			craven = minor_stress_impact_gain 
			chaste = minor_stress_impact_gain
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_greed = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:second_consort
				min = -40
				max = 40
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = shy
				add = -25
			}
			modifier = { #Stress management
				has_trait = craven
				add = -25
			}
			modifier = { #Stress management
				has_trait = chaste
				add = -25
			}	
			modifier = { #Traits
				has_trait = lustful
				add = 25
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:second_consort }
				add = -50
			}
			modifier = {
				exists = primary_spouse
				scope:second_consort = { 
					this = root.primary_spouse
				}
				add = 10
			}
			modifier = {
				scope:second_consort = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = {
				any_spouse = { 
					this = scope:second_consort
				}
				add = 5
			}
			
			modifier = { #Favor
				scope:second_consort = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:second_consort = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:second_consort = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}

			modifier = { #Favor
				scope:second_consort = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = -10
			}
			modifier = { #Favor
				scope:second_consort = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = -20
			}
        }
    }
	
	option = { #Take a walk with the two consorts
        name = harem_politics.0020.c
		random_list = {
			50 = { #Progress towards lovers
				simple_attraction_modifier = {
					WHO = scope:first_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:first_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:first_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					NOT = { scope:first_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:first_consort }
					factor = 0
				}
				if = {
					limit = {
						can_set_relation_potential_lover_trigger = { CHARACTER = scope:first_consort }
					}
					set_relation_potential_lover = scope:first_consort
				}
				scope:first_consort = {
					calyver_favor_minor_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:first_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Nothing
				
			}
		}	
		random_list = {
			50 = { #Progress towards lovers
				simple_attraction_modifier = {
					WHO = scope:second_consort
					TARGET = root
					MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
					MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
				}
				opinion_modifier = {
					opinion_target = scope:second_consort
					min = -50
					max = 50
					multiplier = 0.5
				}
				opinion_modifier = {
					who = scope:second_consort
					opinion_target = root
					min = -50
					max = 50
					multiplier = 0.5
				}
				modifier = {
					NOT = { scope:second_consort = { is_attracted_to_gender_of = root } }
					factor = 0.7
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:second_consort }
					factor = 0
				}
				if = {
					limit = {
						can_set_relation_potential_lover_trigger = { CHARACTER = scope:second_consort }
					}
					set_relation_potential_lover = scope:second_consort
				}
				scope:second_consort = {
					calyver_favor_minor_gain_effect = yes
					add_opinion = {
						target = root
						modifier = romance_opinion
						opinion = 5
					}
				}
				add_opinion = {
					target = scope:second_consort
					modifier = romance_opinion
					opinion = 5
				}
				stress_impact = {
					base = minor_stress_impact_loss
				}
			}
			50 = { #Nothing
				
			}
		}
		
		
		stress_impact = {
			shy = medium_stress_impact_gain 
			craven = medium_stress_impact_gain 
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_greed = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:first_consort
				min = -40
				max = 40
				multiplier = 1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:second_consort
				min = -40
				max = 40
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = shy
				add = -25
			}
			modifier = { #Stress management
				has_trait = craven
				add = -25
			}
			modifier = { 
				has_trait = gregarious
				add = 10
			}	
        }
    }
	
	option = { #Continue with the walk
        name = harem_politics.0020.d
		scope:first_consort = {
			random_list = {
				50 = { #Disappointed
					simple_attraction_modifier = {
						WHO = scope:first_consort
						TARGET = root
						MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
						MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
					}
					opinion_modifier = {
						opinion_target = root
						min = -50
						max = 50
						multiplier = 0.5
					}
					modifier = {
						is_attracted_to_gender_of = root
						add = 10
					}
					modifier = {
						OR = {
							has_relation_lover = root
							has_relation_soulmate = root
							has_relation_potential_lover = root
						}
						add = 15
					}
					add_opinion = {
						target = root
						modifier = rejected_me_opinion
					}
				}
				50 = { #Nothing
					modifier = {
						NOT = { is_attracted_to_gender_of = root }
						add = 500
					}
				}
			}
		}	
		scope:second_consort = {
			random_list = {
				50 = { #Disappointed
					simple_attraction_modifier = {
						WHO = scope:second_consort
						TARGET = root
						MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
						MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
					}
					opinion_modifier = {
						opinion_target = root
						min = -50
						max = 50
						multiplier = 0.5
					}
					modifier = {
						is_attracted_to_gender_of = root
						add = 10
					}
					modifier = {
						OR = {
							has_relation_lover = root
							has_relation_soulmate = root
							has_relation_potential_lover = root
						}
						add = 15
					}
					add_opinion = {
						target = root
						modifier = rejected_me_opinion
					}
				}
				50 = { #Nothing
					modifier = {
						NOT = { is_attracted_to_gender_of = root }
						add = 500
					}
				}
			}
		}		
		
		
		stress_impact = {
			base = miniscule_stress_impact_loss
			shy = minor_stress_impact_loss
			craven = minor_stress_impact_loss 
			reclusive = minor_stress_impact_loss
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_honor = -0.10
				ai_greed = -0.1
				ai_boldness = -0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:first_consort
				min = -40
				max = 40
				multiplier = -1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:second_consort
				min = -40
				max = 40
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = shy
				add = 25
			}
			modifier = { #Stress management
				has_trait = craven
				add = 25
			}
			modifier = { 
				has_trait = chaste
				add = 15
			}
			modifier = { 
				has_trait = gregarious
				add = -25
			}	
			modifier = { 
				has_trait = lustful
				add = -15
			}	
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:first_consort }
				add = 15
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:second_consort }
				add = 15
			}
        }
    }
	
	after = {
		add_character_flag = {
			flag = had_walking_consorts_event_flag
			years = 4
		}
	}
}

###################################################
##A consort was caught trying to ruin a pregnancy##
###################################################
harem_politics.0021 = {
	type = character_event
	title = consort_events.0017.t
	desc = harem_politics.0021.desc
	theme = corruption
	override_background = {
		reference = throne_room
	}
	
	right_portrait = { 	
		character = scope:schemer
		animation = shock
	}
	left_portrait = { 	
		character = scope:pregnant_consort
		animation = disbelief
	}
	
	trigger = {
		is_landed_or_landless_administrative = yes
	}
	
	immediate = {
		save_scope_as = harem_liege
		hidden_effect = {
			scope:actor = {	
				send_interface_toast = {
					type = event_generic_bad
					title = unsuccessful_miscarriage_t
					right_icon = scope:recipient
					custom_tooltip = unsuccessful_miscarriage_caught_desc
				}
				save_scope_as = schemer
				clear_saved_scope = actor
			}
			scope:recipient = {	
				add_opinion = {
					target = scope:schemer
					modifier = hatred_spouse_opinion
				}
				save_scope_as = pregnant_consort
				clear_saved_scope = recipient
			}
		}
		save_scope_as = actor
	}
	
	option = { #Arrest them!
        name = harem_politics.0021.a
		trigger = {
			is_liege_or_above_of = scope:schemer
		}
		add_opinion = {
			target = scope:schemer
			modifier = attempted_miscarriage
		}
		scope:schemer = {
			save_scope_as = recipient
			if = { #If they're a GC, demote them
				limit = {
					has_court_position = grand_consort_court_position
				}
				save_scope_as = employee
				root = {
					save_scope_as = liege
				}
				grand_consort_revoked_court_position_effect = yes
			}
			else = {
				calyver_favor_big_loss_effect = yes
			}

			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:schemer
				}
			}
		}
		imprison = {
			target = scope:schemer
			type = house_arrest
		}
		scope:pregnant_consort = {
			punishment_consort_opinion_mild_effect = yes
		}
		trigger_event = harem_politics.1000
		stress_impact = {
			forgiving = minor_stress_impact_gain 
			compassionate = minor_stress_impact_gain 
		}
		
        ai_chance = {
            base = 50
			
			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -20
				max = 20
				multiplier = -1
			}
			opinion_modifier = { #Opinion of pregnant consort
				opinion_target = scope:pregnant_consort
				min = -20
				max = 20
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = -50
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -50
			}
				
			modifier = { #Traits
				has_trait = just
				add = 10
			}
			modifier = { #Traits
				has_trait = vengeful
				add = 15
			}

			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 20
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 25
			}
			
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}

			#Powerful consorts
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 20
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}

			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -35
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}

			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:pregnant_consort = { 
					this = root.primary_spouse
				}
				add = 15
			}
			#Grand consort
			modifier = {
				scope:pregnant_consort = { 
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			#Other spouses
			modifier = {
				scope:pregnant_consort = { 
					is_married = yes
				}
				add = 5
			}
			#More chances if few kids
			modifier = {
				any_child = { 
					count < 3
				}
				add = 10
			}
        }
    }
	
	option = { #Execute them
        name = harem_politics.0021.b
		trigger = {
			is_liege_or_above_of = scope:schemer
			NOT = { 
				scope:schemer = { has_strong_hook = root } 
			}
		}
		scope:pregnant_consort = {
			punishment_consort_opinion_big_effect = yes
		}
		scope:schemer = {
			death = {
				death_reason = death_punishment
				killer = root
			}
			close_relations_opinion_effect = { VICTIM = scope:schemer EXECUTIONER = root }
		}
		
		stress_impact = {
			forgiving = medium_stress_impact_gain 
			compassionate = medium_stress_impact_gain 

			sadistic = medium_stress_impact_loss
			callous = medium_stress_impact_loss
		}
		
        ai_chance = {
            base = 30
			
			modifier = { #Alliances
				scope:schemer = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -20
			}

			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -30
				max = 30
				multiplier = -1
			}
			opinion_modifier = { #Opinion of pregnant consort
				opinion_target = scope:pregnant_consort
				min = -20
				max = 20
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = -50
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -50
			}
				
			modifier = { #Traits
				has_trait = just
				add = 10
			}
			modifier = { #Traits
				has_trait = vengeful
				add = 20
			}

			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 20
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 25
			}

			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = -25
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 15
			}

			#Powerful consorts
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 25
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}

			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -100
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -25
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -25
			}

			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:pregnant_consort = { 
					this = root.primary_spouse
				}
				add = 15
			}
			#Grand consort
			modifier = {
				scope:pregnant_consort = { 
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			#Other spouses
			modifier = {
				scope:pregnant_consort = { 
					is_married = yes
				}
				add = 5
			}
			#More chances if few kids
			modifier = {
				any_child = { 
					count < 3
				}
				add = 10
			}
        }
    }

	option = { #Let them go
        name = consort_events.0001.c
		
		scope:schemer = {
			calyver_favor_medium_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
		}
		scope:pregnant_consort = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:pregnant_consort
				}
			}
			calyver_favor_big_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -25
			}
		}

		stress_impact = {
			just = medium_stress_impact_gain 
			vengeful = medium_stress_impact_gain 
		}
		
        ai_chance = {
            base = 25
			
			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -20
				max = 20
				multiplier = 1
			}
			opinion_modifier = { #Opinion of pregnant consort
				opinion_target = scope:pregnant_consort
				min = -20
				max = 20
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = 10
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = 10
			}
				
			modifier = { #Traits
				has_trait = just
				add = -25
			}
			modifier = { #Traits
				has_trait = vengeful
				add = -50
			}

			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favored_consort_modifier
				}
				add = -10
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 5
			}
			modifier = { #Favor
				scope:pregnant_consort = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 10
			}

			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = -25
			}

			#Powerful consorts
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -20
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}
			modifier = {
				scope:pregnant_consort = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}

			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 50
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}

			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:schemer = { 
					this = root.primary_spouse
				}
				add = 15
			}
			#Grand consort
			modifier = {
				scope:schemer = { 
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			#Other spouses
			modifier = {
				scope:schemer = { 
					is_married = yes
				}
				add = 5
			}
        }
    }
	
	after = {
		scope:pregnant_consort = {
			trigger_event = {
				id = consort_events.0022
				days = 1
			}
		}
	}
}

##############################################
##Noble Consort Hua makes Zhen Huan miscarry##
##############################################

scripted_trigger harem_politics_zhen_huan_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	harem_politics_unfavored_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no

	has_trait = pregnant
	pregnancy_month <= 6
	exists = pregnancy_assumed_father
	pregnancy_assumed_father = {
		this = root
	}
	
	NOR = {
		exists = scope:is_being_divorced
		exists = scope:is_being_set_aside
		
		has_character_flag = attempted_miscarriage_flag
		has_court_position = grand_consort_court_position

		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}		
	}
	
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_hua_gui_fei_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	harem_politics_evil_consort_trigger = yes
	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	
	NOR = {
		this = $ZHEN_HUAN$

		has_relation_friend = $ZHEN_HUAN$
		has_relation_best_friend = $ZHEN_HUAN$
		has_relation_lover = $ZHEN_HUAN$
		has_relation_soulmate = $ZHEN_HUAN$

		exists = scope:is_being_divorced
		exists = scope:is_being_set_aside

		has_trait = calm
		has_trait = shy
		has_trait = craven
		has_trait = temperate

		has_trait = ill
		has_trait = wounded
		has_trait = pregnant

		has_strong_hook = root
	}
	opinion = {
		target = $ZHEN_HUAN$
		value <= 10
	}
	
	OR = {
		AND = { #Zhen Huan is a concubine
			$ZHEN_HUAN$ = {
				is_concubine = yes
			}
			#Then Hua is either a spouse or the GC
			OR = {
				AND = { #If a GC is employed, Hua is either the GC or PS
					root = {
						employs_court_position = grand_consort_court_position
					}
					OR = {
						AND = {
							exists = root.primary_spouse
							this = root.primary_spouse
						}
						has_court_position = grand_consort_court_position
					}
				}
				#Else, Hua is any spouse
				AND = {
					root = {
						NOT = { employs_court_position = grand_consort_court_position }
					}
					is_married = yes
				}
			}
		}
		AND = { #Zhen Huan is a spouse
			$ZHEN_HUAN$ = {
				is_married = yes
			}
			#Then Hua is either the PS or the GC
			OR = {
				AND = {
					exists = root.primary_spouse
					this = root.primary_spouse
				}
				has_court_position = grand_consort_court_position
			}
		}
	}
	OR = { #Traits
		has_trait = sadistic
		has_trait = callous
		has_trait = wrathful
		has_trait = vengeful
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0022 = {
	type = character_event
	title = harem_politics.0022.t
	desc = harem_politics.0022.desc
	theme = unfriendly
	override_background = {
		reference = bedchamber
	}
	
	left_portrait = { 	
		character = root
		animation = worry
	}
	
	right_portrait = { 	
		character = scope:zhen_huan
		animation = pain
	}
	
	lower_center_portrait = { 	
		character = scope:hua_gui_fei
	}
	
	trigger = {
		any_consort = {
			harem_politics_zhen_huan_trigger = yes
			save_temporary_scope_as = temporary_zhen_huan
		}
		any_consort = {
			harem_politics_hua_gui_fei_trigger = { ZHEN_HUAN = scope:temporary_zhen_huan }
		}
		any_consort = {
			is_courtier_of = root
			count >= 4
		}
		
		NOR = { 
			has_character_flag = had_hailan_event_flag 
			has_character_flag = had_hua_gui_fei_event_flag
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	
	weight_multiplier = {
		base = 1
		modifier = { #Scheming consorts
			add = 0.2
			any_consort = {
				has_character_modifier = scheming_consort_modifier
			}
		}
		modifier = { #Many consorts
			add = 0.2
			any_consort = {
				count >= 5
			}
		}
		modifier = { #No heir
			add = 0.1
			any_child = {
				is_alive = yes
				count = 0 
			}
		}
		modifier = { #Count-consorts won't care that much
			add = -0.2
			highest_held_title_tier <= tier_county
		}
		modifier = { #Royal consorts do care
			add = 0.2
			highest_held_title_tier >= tier_kingdom
		}

		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		random_consort = {
			limit = {
				harem_politics_zhen_huan_trigger = yes
			}
			weight = {
				base = 10
				modifier = { #Favored consorts attract more jealousy
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = { #Favored consorts attract more jealousy
					has_character_modifier = favor_boost_modifier
					add = 15
				}
				modifier = { #Favored consorts attract more jealousy
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
				modifier = { #Favored consorts attract more jealousy
					OR = {
						has_relation_best_friend = root
						has_relation_friend = root
					}
					add = 10
				}
				modifier = { #Favored consorts attract more jealousy
					OR = {
						has_relation_soulmate = root
						has_relation_lover = root
					}
					add = 20
				}
				modifier = { #Zhen Huan had good genetic traits
					num_of_good_genetic_traits >= 1
					add = 15
				}
				modifier = { #She didn't have a strong background
					any_close_family_member = {
						NOR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
					}
					add = 10
				}
				modifier = { #She is young
					age <= 24
					add = 10
				}
				modifier = { #She has enemies
					any_relation = {
						type = rival
						is_consort_of = root
						is_courtier_of = root
						harem_politics_evil_consort_trigger = yes
					}
					add = 15
				}
				modifier = { #She has enemies
					any_relation = {
						type = nemesis
						is_consort_of = root
						is_courtier_of = root
						harem_politics_evil_consort_trigger = yes
					}
					add = 30
				}
				modifier = { #She is a concubine
					is_concubine = yes
					add = 25
				}
			}
			save_scope_as = zhen_huan
		}
		
		every_consort = {
			limit = {
				harem_politics_hua_gui_fei_trigger = { ZHEN_HUAN = scope:zhen_huan }
			}
			add_to_list = hua_gui_fei_list
		}
		random_in_list = {
			list = hua_gui_fei_list
			limit = {
				harem_politics_hua_gui_fei_trigger = { ZHEN_HUAN = scope:zhen_huan }
			}
			weight = {
				base = 10
				modifier = { #She isn't the PS
					exists = root.primary_spouse
					NOT = {
						this = root.primary_spouse
					}
					add = 20
				}
				modifier = { #She is a high-ranking consort
					has_court_position = grand_consort_court_position
					add = 10
				}
				modifier = { #She is a high-ranking consort
					is_married = yes
					add = 10
				}
				modifier = { #Arrogant
					has_trait = arrogant
					add = 5
				}
				modifier = { #Ambitious
					has_trait = ambitious
					add = 5
				}
				modifier = { #Callous
					has_trait = callous
					add = 10
				}
				modifier = { #Sadistic
					has_trait = sadistic
					add = 10
				}
				modifier = { #Wrathful
					has_trait = wrathful
					add = 10
				}
				modifier = { 
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = { 
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
				modifier = { #Hua is favored
					OR = {
						has_relation_best_friend = root
						has_relation_friend = root
					}
					add = 10
				}
				modifier = { #Hua is favored
					OR = {
						has_relation_soulmate = root
						has_relation_lover = root
					}
					add = 20
				}
				modifier = { #She has strong background
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
					add = 10
				}
				modifier = { #She has enemies
					OR = {
						has_relation_rival = scope:zhen_huan
						has_relation_nemesis = scope:zhen_huan
					}
					add = 25
				}
				modifier = { #Scheming consorts
					has_character_modifier = scheming_consort_modifier
					add = 5
				}
				modifier = { #Diplomatic consorts
					has_character_modifier = diplomatic_consort_modifier
					add = -15
				}
			}
			save_scope_as = hua_gui_fei
		}
		scope:zhen_huan = {
			end_pregnancy = yes
			hidden_effect = {	
				pregnancy_cleanup_effect = yes
			}
			contract_disease_effect = { 
				DISEASE = ill 
				TREATMENT_EVENT = yes 
			}
			hidden_effect = {
				if = {
					limit = {
						can_set_relation_rival_trigger = { CHARACTER = scope:hua_gui_fei }
					}
					set_relation_rival = { 
						target = scope:hua_gui_fei
						reason = consort_rival_reason
					}
				}
				else_if = {
					limit = {
						can_set_relation_nemesis_trigger = { CHARACTER = scope:hua_gui_fei }
					}
					set_relation_nemesis = { 
						target = scope:hua_gui_fei
						reason = consort_rival_reason 
					}
				}
			}
		}
		hidden_effect = {
			every_consort = {
				if = {
					limit = {
						NOR = {
							this = scope:hua_gui_fei
							has_relation_friend = scope:hua_gui_fei
							has_relation_best_friend = scope:hua_gui_fei
							has_relation_lover = scope:hua_gui_fei
							has_relation_soulmate = scope:hua_gui_fei
						}
						is_courtier_of = root
					}
					add_opinion = {
						target = scope:hua_gui_fei
						modifier = cruelty_opinion
						opinion = -10
					}
					stress_impact = {
						base = minor_stress_impact_gain
					}
				}
			}
			scope:hua_gui_fei = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = insolent_consort_opinion
					opinion = -10
				}
			}
		}
	}
	
	option = { #Summon Hua
        name = harem_politics.0022.a
		
		trigger_event = {
			id = harem_politics.0023
			days = 5
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.10
				ai_energy = 0.1
   			}
			
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -50
				max = 50
				multiplier = 1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:hua_gui_fei
				min = -50
				max = 50
				multiplier = -1
			}
			
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 15
			}
			modifier = {
				OR = {
					has_relation_lover = scope:zhen_huan
					has_relation_soulmate = scope:zhen_huan
					has_relation_friend = scope:zhen_huan
					has_relation_best_friend = scope:zhen_huan
				}
				add = 25
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = {
				scope:zhen_huan = {
					is_married = yes
				}
				add = 5
			}
			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 20
			}
        }
    }
	
	option = { # Ignore Zhen Huan
		name = harem_politics.0022.b
		scope:zhen_huan = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:zhen_huan
				}
			}
			calyver_favor_big_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -25
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = root }
				}
				set_relation_rival = { 
					reason = ignored_suffering_reason
					target = root
				}
			}
		}
		scope:hua_gui_fei = {
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		hidden_effect = {
			every_consort = {
				if = {
					limit = {
						NOR = {
							this = scope:hua_gui_fei
							this = scope:zhen_huan
							has_relation_friend = scope:hua_gui_fei
							has_relation_best_friend = scope:hua_gui_fei
							has_relation_lover = scope:hua_gui_fei
							has_relation_soulmate = scope:hua_gui_fei
						}
					}
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}
		stress_impact = {
			wrathful = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 40
			ai_value_modifier = {
				ai_honor = -0.4
				ai_vengefulness = -0.5
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:hua_gui_fei
				min = -50
				max = 50
				multiplier = -1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -50
				max = 50
				multiplier = 1
			}
			modifier = {
				has_trait = compassionate
				add = 15
			}
			modifier = {
				has_trait = forgiving
				add = 15
			}
			modifier = {
				has_trait = vengeful
				add = -25
			}
			modifier = {
				has_trait = wrathful
				add = -25
			}
			modifier = {
				has_trait = sadistic
				add = -25
			}
			modifier = {
				has_trait = callous
				add = -25
			}
			modifier = {
				has_trait = diligent
				add = -15
			}
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 5
			}
			#Favor
			modifier = {
				OR = {
					has_relation_lover = scope:hua_gui_fei
					has_relation_soulmate = scope:hua_gui_fei
					has_relation_friend = scope:hua_gui_fei
					has_relation_best_friend = scope:hua_gui_fei
				}
				add = 1
			}
			modifier = {
				scope:hua_gui_fei = {
					harem_politics_favored_consort_trigger = yes
				}
				add = 5
			}
			modifier = {
				scope:hua_gui_fei = {
					is_married = yes
				}
				add = 1
			}
		}
	}	

	after = {
		add_character_flag = had_hua_gui_fei_event_flag
	}
}

harem_politics.0023 = {
	type = character_event
	title = harem_politics.0022.t
	desc = harem_politics.0023.desc
	theme = unfriendly
	override_background = {
		reference = throne_room
	}
	
	left_portrait = { 	
		character = scope:hua_gui_fei
		animation = beg
	}
	
	right_portrait = { 	
		character = root
		animation = rage
	}
	
	lower_center_portrait = { 	
		character = scope:zhen_huan
	}
	
	trigger = {
		is_landed_or_landless_administrative = yes
	}
	
	immediate = {
	}
	
	option = { # Arrest Hua
		name = harem_politics.0023.a
		save_scope_as = actor
		scope:zhen_huan = {
			calyver_favor_moderate_gain_effect = yes
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
			if = { 
				limit = { 
					NOR = { 
						has_trait = forgiving
						has_trait = compassionate
						has_trait = temperate
						has_trait = calm
					}
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -15
				}
			}
			else = {
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 10
				}
			}
		}
		scope:hua_gui_fei = {
			if = { #If they're a GC, demote them
				limit = {
					has_court_position = grand_consort_court_position
				}
				save_scope_as = employee
				root = {
					save_scope_as = liege
				}
				grand_consort_revoked_court_position_effect = yes
			}
			else = {
				calyver_favor_big_loss_effect = yes
			}
			
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:hua_gui_fei
				}
			}
			add_opinion = {
				target = scope:zhen_huan
				modifier = hatred_spouse_opinion
			}
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -10
			}
			save_scope_as = recipient
		}
		imprison = {
			target = scope:hua_gui_fei
			type = house_arrest
		}
		hidden_effect = {
			add_opinion = {
				target = scope:hua_gui_fei
				modifier = cruelty_opinion
				opinion = -20
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_honor = 0.2
				ai_vengefulness = 0.2
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:hua_gui_fei
				min = -50
				max = 50
				multiplier = -1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -50
				max = 50
				multiplier = 1
			}
			modifier = {
				has_trait = compassionate
				add = -25
			}
			modifier = {
				has_trait = forgiving
				add = -25
			}
			modifier = {
				has_trait = temperate
				add = 15
			}
			
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 15
			}
			#Favor
			modifier = {
				OR = {
					has_relation_lover = scope:zhen_huan
					has_relation_soulmate = scope:zhen_huan
					has_relation_friend = scope:zhen_huan
					has_relation_best_friend = scope:zhen_huan
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = {
				scope:zhen_huan = {
					is_married = yes
				}
				add = 5
			}			
			
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -20
			}
			#Favor
			modifier = {
				OR = {
					has_relation_lover = scope:hua_gui_fei
					has_relation_soulmate = scope:hua_gui_fei
					has_relation_friend = scope:hua_gui_fei
					has_relation_best_friend = scope:hua_gui_fei
				}
				add = -15
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favored_consort_modifier
				}
				add = -5
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favor_boost_modifier
				}
				add = -10
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -15
			}

			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -100
			}
			modifier = {
				exists = primary_spouse
				primary_spouse = {
					this = scope:hua_gui_fei
				}
				add = -10
			}
			modifier = {
				scope:hua_gui_fei = {
					has_court_position = grand_consort_court_position
				}
				add = -5
			}
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 100
			}
			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 10
			}
		}
		trigger_event = harem_politics.1000
	}
	
	option = { # Kill Hua
		name = harem_politics.0023.b
		scope:zhen_huan = {
			calyver_favor_huge_gain_effect = yes
			hidden_effect = {
				add_character_modifier = { 
					modifier = safe_disease_treatment_success_high_modifier 
					days = disease_treatment_short_duration 
				}
			}
			if = { 
				limit = { 
					NOR = { 
						has_trait = forgiving
						has_trait = compassionate
						has_trait = temperate
						has_trait = calm
					}
				}
				add_opinion = {
					modifier = pleased_opinion
					target = root
					opinion = 10
				}
			}
			else = {
				add_opinion = {
					target = root
					modifier = cruelty_opinion
					opinion = -20
				}
			}
		}
		scope:hua_gui_fei = {
			save_scope_as = secondary_recipient
			death = {
				death_reason = death_punishment
				killer = root
			}
			close_relations_opinion_effect = { VICTIM = scope:hua_gui_fei EXECUTIONER = root }
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			
			wrathful = medium_stress_impact_loss
			vengeful = medium_stress_impact_loss
			callous = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
		}
		ai_chance = {
			base = 15
			ai_value_modifier = {
				ai_honor = -0.2
				ai_vengefulness = 0.25
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:hua_gui_fei
				min = -50
				max = 50
				multiplier = -1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -50
				max = 50
				multiplier = 1
			}
			modifier = {
				has_trait = compassionate
				add = -25
			}
			modifier = {
				has_trait = forgiving
				add = -25
			}
			modifier = {
				has_trait = vengeful
				add = 15
			}
			modifier = {
				has_trait = wrathful
				add = 15
			}
			modifier = {
				has_trait = sadistic
				add = 15
			}
			modifier = {
				has_trait = callous
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 15
			}
			#Favor
			modifier = {
				OR = {
					has_relation_lover = scope:zhen_huan
					has_relation_soulmate = scope:zhen_huan
					has_relation_friend = scope:zhen_huan
					has_relation_best_friend = scope:zhen_huan
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = {
				scope:zhen_huan = {
					is_married = yes
				}
				add = 5
			}			
			
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -50
			}
			#Favor
			modifier = {
				NOR = {
					has_relation_lover = scope:hua_gui_fei
					has_relation_soulmate = scope:hua_gui_fei
					has_relation_friend = scope:hua_gui_fei
					has_relation_best_friend = scope:hua_gui_fei
				}
				add = 15
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favored_consort_modifier
				}
				add = -10
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}

			modifier = {
				scope:hua_gui_fei = {
					is_concubine = yes
				}
				add = 5
			}
			modifier = {
				scope:hua_gui_fei = {
					is_lowborn = yes
				}
				add = 10
			}
			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 20
			}
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -200
			}
			modifier = {
				exists = primary_spouse
				primary_spouse = {
					this = scope:hua_gui_fei
				}
				add = -20
			}
			modifier = {
				scope:hua_gui_fei = {
					has_court_position = grand_consort_court_position
				}
				add = -10
			}
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 50
			}
		}
	}
	
	option = { # Ignore Zhen Huan
		name = harem_politics.0022.b
		scope:zhen_huan = {
			if = {
				limit = {
					has_character_modifier = favor_boost_modifier
				}
				calyver_stop_favor_boost_event_effect = {
					HAREM_LIEGE = root
					CONSORT = scope:zhen_huan
				}
			}
			calyver_favor_big_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -25
			}
			if = {
				limit = {
					can_set_relation_rival_trigger = { CHARACTER = root }
				}
				set_relation_rival = { 
					reason = ignored_suffering_reason
					target = root
				}
			}
		}
		scope:hua_gui_fei = {
			calyver_favor_medium_gain_effect = yes
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		hidden_effect = {
			every_consort = {
				if = {
					limit = {
						NOR = {
							this = scope:hua_gui_fei
							this = scope:zhen_huan
							has_relation_friend = scope:hua_gui_fei
							has_relation_best_friend = scope:hua_gui_fei
							has_relation_lover = scope:hua_gui_fei
							has_relation_soulmate = scope:hua_gui_fei
						}
					}
					add_opinion = {
						target = root
						modifier = disappointed_opinion
						opinion = -15
					}
				}
			}
		}
		stress_impact = {
			wrathful = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_honor = -0.4
				ai_vengefulness = -0.5
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:hua_gui_fei
				min = -50
				max = 50
				multiplier = -1
			}
			opinion_modifier = { #Opinion
				opinion_target = scope:zhen_huan
				min = -50
				max = 60
				multiplier = 1
			}
			modifier = {
				has_trait = compassionate
				add = 15
			}
			modifier = {
				has_trait = forgiving
				add = 15
			}
			modifier = {
				has_trait = vengeful
				add = -25
			}
			modifier = {
				has_trait = wrathful
				add = -25
			}
			modifier = {
				has_trait = sadistic
				add = -25
			}
			modifier = {
				has_trait = callous
				add = -25
			}
			modifier = {
				has_trait = diligent
				add = -15
			}
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			#Favor
			modifier = {
				OR = {
					has_relation_lover = scope:hua_gui_fei
					has_relation_soulmate = scope:hua_gui_fei
					has_relation_friend = scope:hua_gui_fei
					has_relation_best_friend = scope:hua_gui_fei
				}
				add = 5
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
			modifier = {
				scope:hua_gui_fei = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}

			modifier = {
				scope:hua_gui_fei = {
					is_married = yes
				}
				add = 5
			}			
			
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						OR = {
							is_allied_to = root
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -20
			}
			#Favor
			modifier = {
				NOR = {
					has_relation_lover = scope:zhen_huan
					has_relation_soulmate = scope:zhen_huan
					has_relation_friend = scope:zhen_huan
					has_relation_best_friend = scope:zhen_huan
				}
				add = 15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favored_consort_modifier
				}
				add = -10
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = favor_boost_modifier
				}
				add = -15
			}
			modifier = {
				scope:zhen_huan = {
					has_character_modifier = beloved_consort_modifier
				}
				add = -20
			}

			modifier = {
				scope:zhen_huan = {
					is_concubine = yes
				}
				add = 5
			}
			modifier = {
				scope:zhen_huan = {
					is_lowborn = yes
				}
				add = 5
			}
			modifier = {
				scope:hua_gui_fei = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 70
			}
			modifier = {
				exists = primary_spouse
				primary_spouse = {
					this = scope:hua_gui_fei
				}
				add = 5
			}
			modifier = {
				scope:zhen_huan = {
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -150
			}
			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = -20
			}
		}
	}
}

############################
##Requesting a performance##
############################

scripted_trigger harem_politics_valid_performer_summoning_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root
	is_knight = no

	harem_politics_punished_consort_trigger = no
	harem_politics_forgotten_consort_trigger = no
	is_demoted_consort_trigger = no
	
	NOR = {
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic

		has_trait = clubfooted
		has_trait = hunchbacked
		has_trait = wheezing
		has_trait = spindly
		has_trait = one_eyed
		has_trait = one_legged
		has_trait = disfigured

		has_trait = wounded

		has_trait = infirm
		has_trait = incapable

		has_trait = maimed
		has_trait = blind
		has_trait = ill
		has_trait = bubonic_plague
		has_trait = cancer
		has_trait = consumption
		has_trait = great_pox
		has_trait = gout_ridden
		has_trait = leper
		has_trait = lovers_pox
		has_trait = pneumonic
		has_trait = smallpox
		has_trait = typhus
		has_trait = physique_bad_3
		
		has_trait = dysentery
		has_trait = ergotism
		has_trait = measles

		has_trait = beauty_bad

		has_trait = pregnant

		has_character_modifier = forgotten_consort_modifier
	}

	OR = { #They must be good at something
		diplomacy >= 9
		has_trait = poet
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_effect consort_performance_effect = {
	random_list = {
		50 = { #Good performance
			simple_attraction_modifier = {
				WHO = $CONSORT$
				TARGET = root
				MAX_PERSONALITY = 10 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 10 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = $CONSORT$
				min = -10
				max = 10
				multiplier = 0.1
			}
			opinion_modifier = {
				who = $CONSORT$
				opinion_target = root
				min = -10
				max = 10
				multiplier = 0.1
			}
			modifier = {
				has_relation_lover = $CONSORT$
				add = 5
			}
			modifier = {
				has_relation_friend = $CONSORT$
				add = 5
			}
			modifier = {
				has_relation_soulmate = $CONSORT$
				add = 10
			}
			modifier = {
				has_relation_best_friend = $CONSORT$
				add = 10
			}

			modifier = { #Favor
				add = 5
				$CONSORT$ = {	
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = { #Favor
				add = 10
				$CONSORT$ = {	
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = { #Favor
				add = 15
				$CONSORT$ = {	
					has_character_modifier = beloved_consort_modifier
				}
			}
			
			modifier = { #diplomacy
				add = 5
				$CONSORT$ = {	
					diplomacy >= 12
				}
			}
			modifier = { #diplomacy
				add = 5
				$CONSORT$ = {	
					diplomacy >= 15
				}
			}
			modifier = { #diplomacy
				add = 5
				$CONSORT$ = {	
					diplomacy >= 20
				}
			}
			modifier = { #Poet
				add = 25
				$CONSORT$ = {	
					has_trait = poet
				}
			}
			
			modifier = { #Diplomat
				add = 10
				$CONSORT$ = {	
					has_trait = education_diplomacy_3
				}
			}
			modifier = { #Diplomat
				add = 15
				$CONSORT$ = {	
					has_trait = education_diplomacy_4
				}
			}
			modifier = { #Diplomat
				add = 20
				$CONSORT$ = {	
					has_trait = education_diplomacy_5
				}
			}
			
			modifier = { #Diplomatic consorts will try their best to sleep with root
				$CONSORT$ = { 
					has_character_modifier = diplomatic_consort_modifier
				}
				add = 5
			}

			modifier = { #Gregarious
				add = 10
				$CONSORT$ = {	
					has_trait = gregarious
				}
			}
			modifier = { #Gregarious
				add = 10
				has_trait = gregarious
			}
			modifier = {
				NOT = { $CONSORT$ = { is_attracted_to_gender_of = root } }
				factor = 0.7
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = $CONSORT$ }
				factor = 0
			}
			trigger_event = {
				id = harem_politics.0025
				days = 7
			}	
		}
		30 = { #Bad visit
			simple_attraction_modifier = {
				WHO = $CONSORT$
				TARGET = root
				MAX_PERSONALITY = 10 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 10 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = $CONSORT$
				min = -10
				max = 10
				multiplier = -0.1
			}
			opinion_modifier = {
				who = $CONSORT$
				opinion_target = root
				min = -10
				max = 10
				multiplier = -0.1
			}
			modifier = {
				has_relation_rival = $CONSORT$
				add = 10
			}
			modifier = {
				has_relation_nemesis = $CONSORT$
				add = 20
			}
			
			modifier = { #diplomacy
				add = 5
				$CONSORT$ = {	
					diplomacy <= 10
				}
			}
			modifier = { #diplomacy
				add = 5
				$CONSORT$ = {	
					diplomacy <= 5
				}
			}

			modifier = { #Favor
				add = 10
				$CONSORT$ = {	
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = { #Favor
				add = 20
				$CONSORT$ = {	
					has_character_modifier = forgotten_consort_modifier
				}
			}


			modifier = { #Shy
				add = 10
				$CONSORT$ = {	
					has_trait = shy
				}
			}
			modifier = { #Craven
				add = 5
				$CONSORT$ = {	
					has_trait = craven
				}
			}
			modifier = { #Shy
				add = 10
				has_trait = shy
			}

			modifier = { #Beauty
				add = 10
				$CONSORT$ = {	
					has_trait = beauty_bad_1
				}
			}
			modifier = { #Beauty
				add = 20
				$CONSORT$ = {	
					has_trait = beauty_bad_2
				}
			}
			modifier = { #Beauty
				add = 30
				$CONSORT$ = {	
					has_trait = beauty_bad_3
				}
			}

			modifier = { #Intellect
				add = 5
				$CONSORT$ = {	
					has_trait = intellect_bad_1
				}
			}
			modifier = { #Intellect
				add = 10
				$CONSORT$ = {	
					has_trait = intellect_bad_2
				}
			}
			modifier = { #Intellect
				add = 15
				$CONSORT$ = {	
					has_trait = intellect_bad_3
				}
			}

			modifier = { #Physique
				add = 5
				$CONSORT$ = {	
					has_trait = physique_bad_2
				}
			}
			modifier = { #Physique
				add = 10
				$CONSORT$ = {	
					has_trait = physique_bad_3
				}
			}

			modifier = { #Forced consorts
				add = 30
				$CONSORT$ = {	
					has_opinion_modifier = {
						modifier = forced_me_concubine_marriage_opinion
						target = root
					}
				}
			}

			modifier = {
				NOT = { $CONSORT$ = { is_attracted_to_gender_of = root } }
				add = 25
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = $CONSORT$ }
				add = 25
			}
			trigger_event = {
				id = harem_politics.0026
				days = 7
			}	
		}
	}
}

harem_politics.0024 = {
	type = character_event
	title = harem_politics.0024.t
	desc = harem_politics.0024.desc
	theme = family
	override_background = {
		reference = study
	}
	
	right_portrait = { 	
		character = root
		animation = boredom
	}
	left_portrait = { 	
		character = scope:performer_1
		animation = flirtation_left
	}
	
	lower_left_portrait = { 	
		character = scope:performer_2
	}
	lower_right_portrait = { 	
		trigger = {
			exists = scope:performer_3
		}
		character = scope:performer_3
	}
	
	trigger = {
		any_consort = {
			harem_politics_valid_performer_summoning_trigger = yes
			count >= 2
		}
		
		NOR = {	
			has_character_flag = summoned_performer_event_flag
			has_character_modifier = mourner_modifier
		}
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		has_character_flag = flag_had_performing_consorts_event
	}
	
	weight_multiplier = {
		base = 1
		modifier = { #Many consorts
			add = 0.2
			any_consort = {
				count >= 4
			}
		}
		modifier = { #Poets
			add = 0.4
			any_consort = {
				has_trait = poet
				is_courtier_of = root
			}
		}
		modifier = { #Stress
			add = 0.1
			stress_level >= 1
		}
		modifier = { #Stress
			add = 0.1
			stress_level >= 2
		}
		modifier = { #Stress
			add = 0.5
			stress_level = 3
		}
		modifier = { #Royal consorts
			add = 0.1
			highest_held_title_tier >= tier_kingdom
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		random_consort = {
			limit = {
				harem_politics_valid_performer_summoning_trigger = yes
			}
			weight = {
				base = 20
				modifier = {
					is_concubine = yes
					add = 15
				}
				modifier = {
					is_lowborn = yes
					add = 10
				}

				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}

				modifier = { #Diplomacy
					add = {
						value = diplomacy
						multiply = 1.5
					}
				}

				modifier = { #Diplomacy
					add = 5
					has_trait = education_diplomacy_3
				}
				modifier = { #Diplomacy
					add = 10
					has_trait = education_diplomacy_4
				}
				modifier = { #Diplomacy
					add = 10
					has_trait = education_diplomacy_5
				}

				modifier = { #Beautiful
					add = 10
					has_trait = beauty_good
				}
				modifier = { #Beautiful
					add = 5
					has_trait = beauty_good_2
				}
				modifier = { #Beautiful
					add = 10
					has_trait = beauty_good_3
				}

				modifier = { #Intelligent
					add = 5
					has_trait = intellect_good
				}
				modifier = { #Intelligent
					add = 10
					has_trait = intellect_good_2
				}
				modifier = { #Intelligent
					add = 15
					has_trait = intellect_good_3
				}

				modifier = { #Diplomatic consorts
					add = 10
					has_character_modifier = diplomatic_consort_modifier
				}

				modifier = { #Poet
					add = 100
					has_trait = poet
				}

				modifier = { #Shy
					add = -10
					has_trait = shy
				}
				modifier = { #Craven
					add = -10
					has_trait = craven
				}
			}
			save_scope_as = performer_1
		}
		
		random_consort = {
			limit = {
				harem_politics_valid_performer_summoning_trigger = yes
				NOT = {
					this = scope:performer_1
				}
			}
			weight = {
				base = 20
				modifier = {
					is_concubine = yes
					add = 15
				}
				modifier = {
					is_lowborn = yes
					add = 10
				}
				
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}

				modifier = { #Diplomacy
					add = {
						value = diplomacy
						multiply = 1.5
					}
				}

				modifier = { #Diplomacy
					add = 5
					has_trait = education_diplomacy_3
				}
				modifier = { #Diplomacy
					add = 10
					has_trait = education_diplomacy_4
				}
				modifier = { #Diplomacy
					add = 10
					has_trait = education_diplomacy_5
				}

				modifier = { #Beautiful
					add = 10
					has_trait = beauty_good
				}
				modifier = { #Beautiful
					add = 5
					has_trait = beauty_good_2
				}
				modifier = { #Beautiful
					add = 10
					has_trait = beauty_good_3
				}

				modifier = { #Intelligent
					add = 5
					has_trait = intellect_good
				}
				modifier = { #Intelligent
					add = 10
					has_trait = intellect_good_2
				}
				modifier = { #Intelligent
					add = 15
					has_trait = intellect_good_3
				}

				modifier = { #Diplomatic consorts
					add = 10
					has_character_modifier = diplomatic_consort_modifier
				}

				modifier = { #Poet
					add = 100
					has_trait = poet
				}

				modifier = { #Shy
					add = -10
					has_trait = shy
				}
				modifier = { #Craven
					add = -10
					has_trait = craven
				}
			}
			save_scope_as = performer_2
		}

		if = {
			limit = {
				any_consort = {
					harem_politics_valid_performer_summoning_trigger = yes
					count >= 3
				}
			}
			random_consort = {
				limit = {
					harem_politics_valid_performer_summoning_trigger = yes
					NOR = {
						this = scope:performer_1
						this = scope:performer_2
					}
				}
				weight = {
					base = 20
					modifier = {
						is_concubine = yes
						add = 15
					}
					modifier = {
						is_lowborn = yes
						add = 10
					}
					
					modifier = {
						has_character_modifier = favored_consort_modifier
						add = 10
					}
					modifier = {
						has_character_modifier = beloved_consort_modifier
						add = 20
					}
	
					modifier = { #Diplomacy
						add = {
							value = diplomacy
							multiply = 1.5
						}
					}
	
					modifier = { #Diplomacy
						add = 5
						has_trait = education_diplomacy_3
					}
					modifier = { #Diplomacy
						add = 10
						has_trait = education_diplomacy_4
					}
					modifier = { #Diplomacy
						add = 10
						has_trait = education_diplomacy_5
					}
	
					modifier = { #Beautiful
						add = 10
						has_trait = beauty_good
					}
					modifier = { #Beautiful
						add = 5
						has_trait = beauty_good_2
					}
					modifier = { #Beautiful
						add = 10
						has_trait = beauty_good_3
					}
	
					modifier = { #Intelligent
						add = 5
						has_trait = intellect_good
					}
					modifier = { #Intelligent
						add = 10
						has_trait = intellect_good_2
					}
					modifier = { #Intelligent
						add = 15
						has_trait = intellect_good_3
					}
	
					modifier = { #Diplomatic consorts
						add = 10
						has_character_modifier = diplomatic_consort_modifier
					}
	
					modifier = { #Poet
						add = 100
						has_trait = poet
					}
	
					modifier = { #Shy
						add = -10
						has_trait = shy
					}
					modifier = { #Craven
						add = -10
						has_trait = craven
					}
				}
				save_scope_as = performer_3
			}
		}
	}
	
	option = { #Summon the first performer
        name = harem_politics.0016.a
		
		hidden_effect = {
			scope:performer_1 = {
				save_scope_as = chosen_performer
			}
			consort_performance_effect = { CONSORT = scope:performer_1 }	
		}
		
		stress_impact = {
			shy = minor_stress_impact_gain
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_energy = 0.10
   			}
			opinion_modifier = {
				opinion_target = scope:performer_1
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_1
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
            	add = 10
            	scope:performer_1 = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 15
            	scope:performer_1 = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:performer_1 = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }

			modifier = {
            	add = 10
            	scope:performer_1 = {
            		harem_politics_favored_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 20
            	scope:performer_1 = {
            		harem_politics_beloved_consort_trigger = yes
            	}
            }
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:performer_1
					has_relation_soulmate = scope:performer_1
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:performer_1
					has_relation_friend = scope:performer_1
            	}
            }
            modifier = {
				add = 15
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = 15
				has_trait = lifestyle_reveler
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 1
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 2
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level = 3
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_1
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:performer_1
				}
			}
			
			modifier = { #High diplomacy
				add = scope:performer_1.diplomacy
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_1 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_1 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #PS
				scope:performer_1 = { 
					exists = primary_spouse
					primary_spouse = scope:performer_1
				}
				add = 10
			}

			modifier = {
				add = 25
				scope:performer_1 = { 
					has_trait = poet
				}
			}
        }
    }
	
	option = { #Summon the second performer
		name = harem_politics.0016.b
		
		hidden_effect = {
			scope:performer_2 = {
				save_scope_as = chosen_performer
			}
			consort_performance_effect = { CONSORT = scope:performer_2 }	
		}
		
		stress_impact = {
			shy = minor_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.10
			}
			opinion_modifier = {
				opinion_target = scope:performer_2
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_2
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
				add = 10
				scope:performer_2 = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:performer_2 = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 20
				scope:performer_2 = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = {
				add = 10
				scope:performer_2 = {
					harem_politics_favored_consort_trigger = yes
				}
			}
			modifier = {
				add = 20
				scope:performer_2 = {
					harem_politics_beloved_consort_trigger = yes
				}
			}
			modifier = {
				add = 15
				OR = {
					has_relation_lover = scope:performer_2
					has_relation_soulmate = scope:performer_2
				}
			}
			modifier = {
				add = 10
				OR = {
					has_relation_best_friend = scope:performer_2
					has_relation_friend = scope:performer_2
				}
			}
			modifier = {
				add = 15
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = 15
				has_trait = lifestyle_reveler
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 1
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 2
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level = 3
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_2
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:performer_2
				}
			}
			
			modifier = { #High diplomacy
				add = scope:performer_2.diplomacy
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_2 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_2 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #PS
				scope:performer_2 = { 
					exists = primary_spouse
					primary_spouse = scope:performer_2
				}
				add = 10
			}

			modifier = {
				add = 25
				scope:performer_2 = { 
					has_trait = poet
				}
			}
		}
	}

	option = { #Summon the third performer
		name = harem_politics.0016.c
		trigger = {
			exists = scope:performer_3
		}

		hidden_effect = {
			scope:performer_3 = {
				save_scope_as = chosen_performer
			}
			consort_performance_effect = { CONSORT = scope:performer_3 }	
		}
		
		stress_impact = {
			shy = minor_stress_impact_gain
		}
		
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_energy = 0.10
			}
			opinion_modifier = {
				opinion_target = scope:performer_3
				multiplier = 0.20
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:performer_3
				MAX_PERSONALITY = 30 
				MAX_PHYSICAL = 30 
			}

			modifier = {
				add = 10
				scope:performer_3 = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:performer_3 = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 20
				scope:performer_3 = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = {
				add = 10
				scope:performer_3 = {
					harem_politics_favored_consort_trigger = yes
				}
			}
			modifier = {
				add = 20
				scope:performer_3 = {
					harem_politics_beloved_consort_trigger = yes
				}
			}
			modifier = {
				add = 15
				OR = {
					has_relation_lover = scope:performer_3
					has_relation_soulmate = scope:performer_3
				}
			}
			modifier = {
				add = 10
				OR = {
					has_relation_best_friend = scope:performer_3
					has_relation_friend = scope:performer_3
				}
			}
			modifier = {
				add = 15
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = 15
				has_trait = lifestyle_reveler
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 1
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level >= 2
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = 15
				stress_level = 3
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	
				add = 25
				is_attracted_to_gender_of = scope:performer_3
			}
			modifier = {	
				add = -25
				NOT = {
					is_attracted_to_gender_of = scope:performer_3
				}
			}
			
			modifier = { #High diplomacy
				add = scope:performer_3.diplomacy
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_3
				}
				add = 15
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_2
				}
				add = 10
			}
			modifier = { #Beauty
				scope:performer_3 = { 
					has_trait = beauty_good_1
				}
				add = 5
			}
			modifier = { #Grand Consort
				scope:performer_3 = { 
					has_court_position = grand_consort_court_position
				}
				add = 5
			}
			modifier = { #PS
				scope:performer_3 = { 
					exists = primary_spouse
					primary_spouse = scope:performer_3
				}
				add = 10
			}

			modifier = {
				add = 25
				scope:performer_3 = {
					has_trait = poet
				}
			}
		}
	}

	option = { #Forget it
		name = harem_politics.0020.d
		
		stress_impact = {
			lustful = minor_stress_impact_gain
			lifestyle_reveler = minor_stress_gain
		}
		
		ai_chance = {
			base = 70
			ai_value_modifier = {
				ai_energy = -0.10
				ai_sociability = -0.50
			}
			modifier = {
				add = 15
				has_trait = shy
			}
			modifier = {
				add = -25
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = lifestyle_reveler
			}
			modifier = {	#Weight up for stress.
				add = -15
				stress_level >= 1
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = -20
				stress_level >= 2
				NOT = {
					has_trait = shy
				}
			}
			modifier = {	#Weight up for stress.
				add = -25
				stress_level = 3
				NOT = {
					has_trait = shy
				}
			}
		}
	}

	after = {
		add_character_flag = {
			flag = summoned_performer_event_flag
			years = 4
		}
	}
}

#Good performance#
harem_politics.0025 = {
	type = character_event
	title = harem_politics.0025.t
	desc = {
		desc = harem_politics.0025.start.desc
		first_valid = {
			triggered_desc = { #They're playing an instrument
				trigger = {
					exists = local_var:playing_instrument_variable
				}
				desc = harem_politics.0025.instrument.desc
			}
			triggered_desc = { #They're singing
				trigger = {
					exists = local_var:singing_variable
				}
				desc = harem_politics.0025.singing.desc
			}
			triggered_desc = { #They're reading poetry
				trigger = {
					exists = local_var:poetry_variable
				}
				desc = harem_politics.0025.poetry.desc
			}
			triggered_desc = { #Dancin'
				trigger = {
					exists = local_var:dancing_variable
				}
				desc = harem_politics.0025.dancing.desc
			}
		}
		desc = harem_politics.0025.end.desc
	}
	theme = family
	override_background = {
		reference = bedchamber
	}
	
	right_portrait = { 	
		character = scope:chosen_performer
		animation = happiness
	}
	left_portrait = { 	
		character = root
		animation = ecstasy
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes

		scope:chosen_performer = {
			harem_politics_valid_performer_summoning_trigger = yes
		}
	}
	
	immediate = {
		
		random_list = {
			50 = { #Playing an instrument
				modifier = {
					add = {
						value = scope:chosen_performer.diplomacy
						multiply = 0.7
						max = 50
					}
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = gregarious
					}
					add = 10
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = shy
					}
					add = -15
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = craven
					}
					add = -15
				}
				modifier = {
					scope:chosen_performer = {
						has_court_position = court_musician_court_position
					}
					add = 25
				}
				set_local_variable = {
					name = playing_instrument_variable
					value = yes
				}
			}
			
			50 = { #Singing
				modifier = {
					add = {
						value = scope:chosen_performer.diplomacy
						multiply = 0.7
						max = 50
					}
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = poet
					}
					add = 10
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = shy
					}
					add = -15
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = craven
					}
					add = -15
				}
				modifier = {
					scope:chosen_performer = {
						has_court_position = court_musician_court_position
					}
					add = 25
				}
				set_local_variable = {
					name = singing_variable
					value = yes
				}
			}
			50 = { #Dancing
				modifier = {
					add = {
						value = scope:chosen_performer.diplomacy
						multiply = 0.7
						max = 50
					}
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = gregarious
					}
					add = 10
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = shy
					}
					add = -15
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = craven
					}
					add = -15
				}
				set_local_variable = {
					name = dancing_variable
					value = yes
				}
			}
			
			50 = { #Reading poetry
				modifier = {
					add = {
						value = scope:chosen_performer.learning
						multiply = 0.7
						max = 50
					}
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = poet
					}
					add = 100
				}
				
				modifier = {
					scope:chosen_performer = {
						has_trait = education_learning_1
					}
					add = 5
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = education_learning_2
					}
					add = 10
				}
				modifier = {
					scope:chosen_performer = {
						has_trait = education_learning_3
					}
					add = 15
				}
				modifier = {
					scope:chosen_performer = {
						OR = {
							has_trait = education_learning_4
							has_trait = education_learning_5
						}
					}
					add = 20
				}
				modifier = {
					scope:chosen_performer = {
						has_court_position = court_poet_court_position
					}
					add = 25
				}
				set_local_variable = {
					name = poetry_variable
					value = yes
				}
			}
		}

		if = {
			limit = {
				NOT = { has_trait = shy }
			}
			stress_impact = {
				base = minor_stress_impact_loss
			}
		}
		add_opinion = {
			target = scope:chosen_performer
			modifier = admiration_opinion
			opinion = 10
		}
		scope:chosen_performer = {
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				target = root
				modifier = flattered_opinion
				opinion = 10
			}
		}
	}
	
	option = { #Spend the night with chosen_performer
        name = harem_events.0025.a
		trigger = {
			NOR = {
				has_trait = eunuch
				has_trait = celibate
				has_trait = devoted
			}
		}
		
		had_sex_with_effect = {
			CHARACTER = scope:chosen_performer
			PREGNANCY_CHANCE = pregnancy_chance
		}
		stress_impact = {
			chaste = minor_stress_impact_gain
		}

		scope:chosen_performer = {
			hidden_effect = {
				#Clear unfavored effect
				clear_negative_consort_modifiers_effect = yes
				#Increase favor effect
				increase_favor_modifier_effect = { TIME = 3 }
			}
			if = {
				limit = { can_set_relation_potential_lover_trigger = { CHARACTER = root } }
				set_relation_potential_lover = root
			}
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 5
			}
		}
		add_opinion = {
			target = scope:chosen_performer
			modifier = romance_opinion
			opinion = 5
		}
		
        ai_chance = {
            base = 100
            ai_value_modifier = {
				ai_greed = 0.20
				ai_energy = 0.35
   			}
			modifier = {
				add = 25
				has_trait = lustful
			}
			modifier = {
				add = -20
				has_trait = irritable
			}
			modifier = {
				add = -20
				has_trait = reclusive
			}
			modifier = {
				add = -25
				has_trait = shy
			}
			modifier = {
				add = -25
				has_trait = craven
			}
			modifier = {
				add = -25
				has_trait = chaste
			}

			modifier = {
				add = 10
				scope:chosen_performer = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:chosen_performer = {
					has_character_modifier = favor_boost_modifier
				}
			}
			modifier = {
				add = 20
				scope:chosen_performer = {
					has_character_modifier = beloved_consort_modifier
				}
			}
        }
    }

	option = { #Enough!
        name = harem_events.0002.b
		

		stress_impact = {
			lustful = minor_stress_impact_gain
		}
		scope:chosen_performer = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
			calyver_favor_minor_loss_effect = yes
		}
		
        ai_chance = {
            base = 100
			modifier = {
				add = -25
				has_trait = lustful
			}
			modifier = {
				add = 20
				has_trait = reclusive
			}
			modifier = {
				add = 20
				has_trait = chaste
			}

			modifier = {
				add = 5
				scope:chosen_performer = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 10
				scope:chosen_performer = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {	
				add = 25
				NOT = {
					is_attracted_to_gender_of = scope:chosen_performer
				}
			}
        }
    }
}

#Bad performance#
harem_politics.0026 = {
	type = character_event
	title = harem_politics.0025.t
	desc = harem_politics.0026.desc
	theme = family
	override_background = {
		reference = bedchamber
	}
	
	right_portrait = { 	
		character = scope:chosen_performer
		animation = shame
	}
	left_portrait = { 	
		character = root
		animation = disapproval
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes

		scope:chosen_performer = {
			harem_politics_valid_performer_summoning_trigger = yes
		}
	}
	
	immediate = {
		add_opinion = {
			target = scope:chosen_performer
			modifier = disappointed_opinion
			opinion = -5
		}
	}

	option = { #Enough!
        name = bride_show.0007.a
		
		scope:chosen_performer = {
			calyver_favor_minor_loss_effect = yes
			if = {
				limit = { 
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					is_attracted_to_gender_of = root
					hp_accepts_harems = yes
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
		}
		
        ai_chance = {
            base = 100
        }
    }
}

#########################################
##Your consorts don't like Consort Rong##
#########################################

scripted_trigger harem_politics_rong_fei_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	harem_politics_unfavored_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no

	#Isn't unfavored
	trigger_if = {
		limit = {
			has_variable = favor
		}
		var:favor >= neutral_consort_lower_limit
	}
	has_character_modifier = favor_boost_modifier
	
	OR = {
		has_character_flag = flag_new_consort
		has_trait = beauty_good_2
		has_trait = beauty_good_3
		var:favor >= favorite_consort_lower_limit
	}

	NOR = {
		exists = scope:is_being_divorced
		exists = scope:is_being_set_aside

		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}	
	}
	
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_ying_fei_trigger = {
	is_physically_able_adult = yes
	is_healthy = yes
	is_courtier_of = root
	is_imprisoned = no
	hp_accepts_harems = yes
	harem_politics_punished_consort_trigger = no
	NOR = {
		this = $RONG$
		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		has_trait = forgiving
		has_trait = compassionate
		has_trait = content
		has_trait = humble

		has_trait = shy
		has_trait = craven

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}

		has_relation_potential_friend = $RONG$
		has_relation_friend = $RONG$
		has_relation_best_friend = $RONG$

		has_relation_potential_lover = $RONG$
		has_relation_lover = $RONG$
		has_relation_soulmate = $RONG$
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0027 = {
	type = character_event
	title = harem_politics.0019.t
	desc = harem_politics.0027.desc
	theme = family
	override_background = {
		reference = garden
	}
	
	right_portrait = { 	
		character = root
		animation = eyeroll
	}
	left_portrait = { 	
		character = scope:ying_pin
		animation = disgust
	}
	lower_center_portrait = { 	
		character = scope:rong_fei
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		any_consort = {
			harem_politics_rong_fei_trigger = yes
			save_temporary_scope_as = rong_check
		}
		any_consort = {
			harem_politics_ying_fei_trigger = { RONG = scope:rong_check }
			count >= 2
		}
		NOT = {
			has_character_flag = had_ying_and_rong_event_flag
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		random_consort = {
			limit = {
				has_character_modifier = favor_boost_modifier
			}
			save_scope_as = rong_fei
		}

		every_consort = {
			limit = {
				harem_politics_ying_fei_trigger = { RONG = scope:rong_fei }
			}
			add_to_list = ying_pin_list
			hidden_effect = {
				add_opinion = {
					target = scope:rong_fei
					modifier = jealousy_opinion
					opinion = -5
				}
			}
		}
		random_in_list = {
			list = ying_pin_list
			weight = {
				base = 10
				modifier = { #She is a high-ranking consort
					has_court_position = grand_consort_court_position
					add = 30
				}
				modifier = { #She is a high-ranking consort
					is_married = yes
					NOT = {
						has_court_position = grand_consort_court_position
					}
					add = 20
				}

				modifier = { #Evil consorts won't stand another favorite
					harem_politics_evil_consort_trigger = yes
					add = 5
				}
				modifier = { #Arrogant consorts won't stand another favorite
					has_trait = arrogant
					add = 5
				}
				modifier = { #Ambitious consorts won't stand another favorite
					has_trait = ambitious
					add = 5
				}
				modifier = { #Brave consorts won't fear liege
					has_trait = brave
					add = 10
				}
				
				modifier = { #Unfavored consorts won't be so daring
					has_character_modifier = unfavored_consort_modifier
					add = -5
				}
				modifier = { #Unfavored consorts won't be so daring
					has_character_modifier = forgotten_consort_modifier
					add = -10
				}

				modifier = { #Favored consorts dare more
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = { #Favored consorts dare more
					has_character_modifier = beloved_consort_modifier
					add = 20
				}

				modifier = {
					NOR = {
						has_relation_best_friend = root
						has_relation_friend = root
					}
					add = 10
				}
				modifier = {
					NOR = {
						has_relation_soulmate = root
						has_relation_lover = root
					}
					add = 20
				}

				modifier = { #Having a strong background makes you more daring
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_liege_or_above_of = root
						}
						NOT = {
							is_child_of = root
						}
					}
					add = 10
				}

				modifier = { #Diplomatic consorts
					has_character_modifier = diplomatic_consort_modifier
					add = -15
				}

				opinion_modifier = {
					opinion_target = scope:rong_fei
					multiplier = -0.10
				}
			}
			save_scope_as = ying_pin
		}
	}

	option = { #Scold Ying
        name = harem_politics.0027.a
		scope:ying_pin = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -15
			}
			add_character_flag = {
				flag = flag_scolded_consort
				years = 1
			}
		}
		scope:rong_fei = {
			calyver_favor_minor_gain_effect = yes
			if = {
				limit = { 
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					hp_accepts_harems = yes
					opinion = {
						target = root
						value >= -10
					}
				}
				add_opinion = {
					target = root
					modifier = pleased_opinion
					opinion = 10
				}
			}
		}

		hidden_effect = {
			every_in_list = {
				list = ying_pin_list
				limit = {
					NOT = {
						this = scope:ying_pin
					}
				}
				calyver_favor_minor_loss_effect = yes
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
				add_opinion = {
					target = scope:rong_fei
					modifier = jealousy_opinion
					opinion = -5
				}
			}
		}
		
		stress_impact = {
			fickle = minor_stress_impact_gain
		}

        ai_chance = {
            base = 100
			ai_value_modifier = {
				ai_honor = 0.10
				ai_vengefulness = -0.2
   			}
			opinion_modifier = {
				opinion_target = scope:rong_fei
				multiplier = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:ying_pin
				multiplier = 0.15
			}

			modifier = {
				add = 10
				has_trait = lustful
			}
			modifier = {
				add = 10
				has_trait = temperate
			}
			modifier = {
				add = 10
				has_trait = stubborn
			}

			modifier = {
				add = -20
				has_trait = fickle
			}

			modifier = {
				add = 5
				scope:ying_pin = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 10
				scope:ying_pin = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = {
				add = -5
				scope:ying_pin = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -10
				scope:ying_pin = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = 10
				scope:rong_fei = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:rong_fei = {
					has_character_modifier = beloved_consort_modifier
				}
			}
        }
    }

	option = { #Imprison Ying
        name = harem_politics.0027.b
		trigger = {
			scope:ying_pin = {
				NOT = { has_strong_hook = root }
			}
		}
		save_scope_as = actor

		scope:ying_pin = {

			if = { #If they're a GC, demote them
				limit = {
					has_court_position = grand_consort_court_position
				}
				save_scope_as = employee
				root = {
					save_scope_as = liege
				}
				grand_consort_revoked_court_position_effect = yes
			}
			else = {
				calyver_favor_big_loss_effect = yes
			}

			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:rong_fei }
				}
				set_relation_potential_rival = scope:rong_fei
			}
			
			add_opinion = {
				target = scope:rong_fei
				modifier = hatred_spouse_opinion
			}
			
			add_opinion = {
				target = root
				modifier = cruelty_opinion
				opinion = -20
			}
			save_scope_as = recipient
		}
		imprison = {
			target = scope:ying_pin
			type = house_arrest
		}
		hidden_effect = {
			add_opinion = {
				target = scope:ying_pin
				modifier = insolent_consort_opinion
				opinion = -20
			}

			every_in_list = {
				list = ying_pin_list
				limit = {
					NOT = {
						this = scope:ying_pin
					}
				}
				calyver_favor_minor_loss_effect = yes
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -15
				}
				add_opinion = {
					target = scope:rong_fei
					modifier = jealousy_opinion
					opinion = -10
				}
			}
		}

		scope:rong_fei = {
			calyver_favor_medium_gain_effect = yes
			if = {
				limit = { 
					NOT = {
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					hp_accepts_harems = yes
					opinion = {
						target = root
						value >= -10
					}
				}
				add_opinion = {
					target = root
					modifier = pleased_opinion
					opinion = 15
				}
				if = {
					limit = {
						can_set_relation_potential_lover_trigger = { CHARACTER = root }
					}
					set_relation_potential_lover = root
				}
			}
		}

		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			fickle = minor_stress_impact_gain
		}

        ai_chance = {
            base = 100
			ai_value_modifier = {
				ai_honor = -0.10
				ai_vengefulness = 0.2
   			}
			opinion_modifier = {
				opinion_target = scope:rong_fei
				multiplier = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:ying_pin
				multiplier = -0.15
			}

			modifier = {
				add = 10
				has_trait = arbitrary
			}
			modifier = {
				add = 15
				has_trait = vengeful
			}
			modifier = {
				add = 10
				has_trait = stubborn
			}

			modifier = {
				add = -20
				has_trait = compassionate
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			modifier = {
				add = -20
				has_trait = fickle
			}

			modifier = {
				add = -10
				scope:ying_pin = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -20
				scope:ying_pin = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = {
				add = 10
				scope:ying_pin = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:ying_pin = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = 10
				scope:rong_fei = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 20
				scope:rong_fei = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = { #Concubine Ying has a powerful background
				add = -15
				scope:ying_pin = {
					OR = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								highest_held_title_tier >= tier_kingdom
							}
						}
						any_child = {
							is_child_of = root
							count >= 2
						}
					}
				}
			}
        }

		trigger_event = harem_politics.1000
    }

	option = { #Stop favoring Rong
        name = harem_politics.0027.c

		add_character_flag = {
			flag = already_favored_consort_flag
			years = 3
		}
		
		scope:rong_fei = {
			calyver_stop_favor_boost_effect = {
				CONSORT = scope:rong_fei
				HAREM_LIEGE = root
			}
		}

		hidden_effect = {
			every_consort = {
				limit = {				
					is_physically_able_adult = yes
					is_courtier_of = root
					hp_accepts_harems = yes
					OR = {
						AND = {
							is_travelling = yes
							current_travel_plan = {
								travel_plan_owner = root
							}
						}
						AND = {
							is_travelling = no
							root = {
								is_travelling = no
							}
						}
					}
					NOR = {

						this = scope:rong_fei

						has_trait = forgiving
						has_trait = compassionate
						has_trait = content
						has_trait = humble

						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
				}
				add_opinion = {
					target = root
					modifier = pleased_opinion
					opinion = 10
				}
			}
		}
		stress_impact = {
			stubborn = minor_stress_impact_gain
		}

        ai_chance = {
            base = 100
			ai_value_modifier = {
				ai_honor = 0.10
				ai_vengefulness = -0.2
   			}
			opinion_modifier = {
				opinion_target = scope:rong_fei
				multiplier = -0.15
			}
			opinion_modifier = {
				opinion_target = scope:ying_pin
				multiplier = 0.15
			}

			modifier = {
				add = 10
				has_trait = fickle
			}
			modifier = {
				add = -20
				has_trait = stubborn
			}

			modifier = {
				add = 10
				scope:ying_pin = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = 15
				scope:ying_pin = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = {
				add = -5
				scope:ying_pin = {
					has_character_modifier = unfavored_consort_modifier
				}
			}
			modifier = {
				add = -10
				scope:ying_pin = {
					has_character_modifier = forgotten_consort_modifier
				}
			}

			modifier = {
				add = -5
				scope:rong_fei = {
					has_character_modifier = favored_consort_modifier
				}
			}
			modifier = {
				add = -10
				scope:rong_fei = {
					has_character_modifier = beloved_consort_modifier
				}
			}

			modifier = { #Concubine Rong has a powerful background
				add = -15
				scope:rong_fei = {
					OR = {
						any_close_family_member = {
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								highest_held_title_tier >= tier_kingdom
							}
						}
						any_child = {
							is_child_of = root
							count >= 2
						}
					}
				}
			}
        }
    }

	after = {
		add_character_flag = {
			flag = had_ying_and_rong_event_flag
			years = 5
		}
	}
}

######################################
##A consort helps you release stress##
######################################

scripted_trigger harem_politics_relaxing_consort_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no

	hp_accepts_harems = yes

	opinion = {
		target = root
		value >= 5
	}

	stress <= normal_baseline_stress
	
	NOR = {
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic

		has_trait = clubfooted
		has_trait = hunchbacked
		has_trait = wheezing
		has_trait = spindly
		has_trait = one_eyed
		has_trait = one_legged
		has_trait = disfigured

		has_trait = wounded

		has_trait = infirm
		has_trait = incapable

		has_trait = maimed
		has_trait = blind
		has_trait = ill
		has_trait = bubonic_plague
		has_trait = cancer
		has_trait = consumption
		has_trait = great_pox
		has_trait = gout_ridden
		has_trait = leper
		has_trait = lovers_pox
		has_trait = pneumonic
		has_trait = smallpox
		has_trait = typhus
		has_trait = physique_bad_3
		
		has_trait = dysentery
		has_trait = ergotism
		has_trait = measles

		has_relation_rival = root
		has_relation_nemesis = root

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
	}

	OR = {
		#Competent Grand Consort
		AND = {
			has_court_position = grand_consort_court_position
			aptitude = {
				court_position = grand_consort_court_position
				value >= 3
			}
		}
		AND = {
			OR = {
				has_relation_lover = root
				has_relation_soulmate = root
				has_relation_friend = root
				has_relation_best_friend = root
			}
			trait_compatibility = {
				target = root
				value >= medium_positive_trait_compatibility
			}
		}
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0028 = {
	type = character_event
	title = harem_politics.0028.t
	desc = harem_politics.0028.desc
	theme = romance_scheme
	override_background = {
		reference = study
	}
	
	right_portrait = { 	
		character = root
		animation = happiness
	}
	left_portrait = { 	
		character = scope:good_consort
		animation = love
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		any_consort = {
			is_physically_able_ai_adult = yes
			is_courtier_of = root
			count >= 3
		}
		any_consort = {
			harem_politics_relaxing_consort_trigger = yes
		}
		stress >= normal_baseline_stress
		NOT = {
			has_character_flag = had_release_stress_consort_event_flag
		}
	}

	weight_multiplier = {
		base = 1
		modifier = { #Stress
			add = 1
			stress_level >= 1
		}
		modifier = { #Stress
			add = 0.50
			stress_level >= 2
		}
		modifier = { #Stress
			add = 0.50
			stress_level = 3
		}

		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = 0.05
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = 0.05
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = 0.05
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = -0.07
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = -0.08
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				harem_politics_relaxing_consort_trigger = yes
			}
			add_to_list = relaxing_consorts_list
		}

		random_in_list = {
			list = relaxing_consorts_list
			weight = {
				base = 10
				modifier = { #She is a high-ranking consort
					exists = root.primary_spouse
					this = root.primary_spouse
					add = 30
				}
				modifier = { #She is a high-ranking consort
					has_court_position = grand_consort_court_position
					add = 20
				}
				modifier = { #She is a high-ranking consort
					is_married = yes
					add = 10
				}

				modifier = { 
					has_relation_friend = root
					add = 10
				}
				modifier = { 
					has_relation_best_friend = root
					add = 20
				}
				modifier = { 
					has_relation_lover = root
					add = 20
				}
				modifier = {
					has_relation_soulmate = root
					add = 30
				}

				modifier = { #Diplomatic consorts
					has_character_modifier = diplomatic_consort_modifier
					add = 10
				}
			}
			save_scope_as = good_consort
		}
	}

	option = {
        name = harem_politics.0028.a		
		if = {
			limit = {
				stress_level >= 1
			}
			if = {
				limit = {
					stress_level = 3
				}
				stress_impact = {
					base = massive_stress_impact_loss
				}
			}
			else_if = {
				limit = {
					stress_level = 2
				}
				stress_impact = {
					base = major_stress_impact_loss
				}
			}
			else = {
				stress_impact = {
					base = medium_stress_impact_loss
				}
			}
		}
		else = {
			stress_impact = {
				base = minor_stress_impact_loss
			}
		}

		#Opinion and relationship increase, plus favor
		add_opinion = {
			target = scope:good_consort
			modifier = pleased_opinion
			opinion = 10
		}
		scope:good_consort = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
			calyver_favor_minor_gain_effect = yes
			if = {
				limit = {
					can_set_relation_potential_lover_trigger = { CHARACTER = root }
				}
				set_relation_potential_lover = root
			}
		}


        ai_chance = {
            base = 10
        }
    }

	after = {
		add_character_flag = {
			flag = had_release_stress_consort_event_flag
			years = 3
		}
	}
}

##############################################
##A ruler asks you to promote their relative##
##############################################
scripted_trigger harem_politics_valid_ruler_relative_trigger = {
	is_physically_able_ai_adult = yes
	is_travelling = no
	is_at_war = no
	is_landed_or_landless_administrative = yes

	highest_held_title_tier >= tier_county

	#Proper tier difference
	tier_difference = {
		target = root
		value <= 1
	}
	tier_difference = {
		target = root
		value >= -2
	}

	#Proper distance
	OR = {
		in_diplomatic_range = root
		is_liege_or_above_of = root
		is_vassal_or_below_of = root
	}

	#Arrogant characters will only do it if they're root's vassal
	OR = {
		AND = {
			has_trait = arrogant
			is_vassal_or_below_of = root
		}
		NOT = {
			has_trait = arrogant
		}
	}
	
	NOR = {
		has_trait = content
		has_trait = humble

		is_allied_to = root

		is_close_family_of = root
	}
}

scripted_trigger harem_politics_valid_promotion_consort_0029_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	hp_accepts_harems = yes

	any_close_family_member = {
		harem_politics_valid_ruler_relative_trigger = yes
	}

	NOR = {
		AND = {
			exists = root.primary_spouse
			this = root.primary_spouse
		}
		has_character_flag = flag_considered_consort
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0029 = {
	type = letter_event
	opening = {
		first_valid = {
			triggered_desc = { #The sender is liege or above of root
				trigger = {
					scope:sender = {
						is_liege_or_above_of = root
					}
				}
				desc = harem_politics.0029.opening.liege
			}
			triggered_desc = { #The sender outranks root
				trigger = {
					scope:sender = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
				}
				desc = harem_politics.0029.opening.inferior
			}
			triggered_desc = { #The sender is a vassal
				trigger = {
					scope:sender = {
						is_vassal_of = root
					}
				}
				desc = harem_politics.0029.opening.subordinate
			}
			desc = harem_politics.0029.opening.neutral
		}
	}
	desc = {
		first_valid = {
			triggered_desc = { #The sender is liege or above of root
				trigger = {
					scope:sender = {
						is_liege_or_above_of = root
					}
				}
				desc = harem_politics.0029.desc.liege
			}
			triggered_desc = { #The sender outranks root
				trigger = {
					scope:sender = {
						tier_difference = {
							target = root
							value > 0
						}
					}
				}
				desc = harem_politics.0029.desc.superior
			}
			triggered_desc = { #The sender is a powerful vassal
				trigger = {
					scope:sender = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
				}
				desc = harem_politics.0029.desc.powerful_vassal
			}
			triggered_desc = { #The sender is a vassal
				trigger = {
					scope:sender = {
						is_vassal_of = root
					}
				}
				desc = harem_politics.0029.desc.vassal
			}
			triggered_desc = { #Fallback
				desc = harem_politics.0029.desc.fallback
			}
		}
	}
	sender = scope:sender

	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		OR = {
			AND = { #Concubine to spouse
				any_concubine = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
				}
				allowed_more_spouses = yes
			}
			AND = { #Consort to Grand Consort
				NOT = { 
					employs_court_position = grand_consort_court_position
				}
				gold > 0
				any_consort = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
			}
		}
		NOR = {
			has_character_flag = had_ruler_consort_promotion_event_flag
			has_character_modifier = mourner_modifier
		}
	}

	immediate = {
		save_scope_as = harem_liege
		if = {
			limit = {
				any_concubine = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
				}
				allowed_more_spouses = yes
			}
			every_concubine = {
				limit = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
				}
				add_to_list = consort_list
			}
		}
		if = {
			limit = {
				NOT = { 
					employs_court_position = grand_consort_court_position
				}
				can_employ_court_position_type = grand_consort_court_position
				gold > 0
				any_consort = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
					NOT = {
						is_in_list = consort_list
					}
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
			}
			every_consort = {
				limit = {
					harem_politics_valid_promotion_consort_0029_trigger = yes
					NOT = {
						is_in_list = consort_list
					}
					root = {
						can_appoint_char_to_court_position = {
							CHAR = prev
							COURT_POS = grand_consort_court_position
						}
					}
				}
				add_to_list = consort_list
			}
		}

		random_in_list = {
			list = consort_list
			weight = {
				base = 10
				modifier = { #Concubines need to climb up the most
					is_concubine = yes
					add = 20
				}

				modifier = { #Lieges won't stand a relative being a mere concubine
					any_close_family_member = {
						is_liege_or_above_of = root
					}
					add = 25
				}
				modifier = { #Higher ranks won't beg to inferiors
					any_close_family_member = {
						highest_held_title_tier >= tier_county
						tier_difference = {
							target = root
							value <= 0
						}
					}
					add = 15
				}
				modifier = { #Kings won't stand a relative being a mere concubine
					any_close_family_member = {
						highest_held_title_tier >= tier_kingdom
					}
					add = 10
				}
				modifier = { #Neighbors are more dangerous
					any_close_family_member = {
						highest_held_title_tier >= tier_county
						any_sub_realm_county = {
							is_neighbor_to_realm = root
						}
					}
					add = 15
				}

				modifier = { #Superior won't beg to the weak
					any_close_family_member = {
						highest_held_title_tier >= tier_county
						max_military_strength < root.max_military_strength
					}
					add = 10
				}

				modifier = { #Superior won't beg to the weak
					any_close_family_member = {
						is_councillor_of = root
					}
					add = 10
				}
				modifier = { #Superior won't beg to the weak
					any_close_family_member = {
						is_powerful_vassal_of = root
					}
					add = 15
				}

				modifier = { #More likely if the consort wasn't demoted
					is_demoted_consort_trigger = no
					add = 10
				}

				modifier = { #More likely to promote favored consorts
					has_character_modifier = favor_boost_modifier
					add = 10
				}
				modifier = { #More likely to promote favored consorts
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = { #More likely to promote favored consorts
					has_character_modifier = beloved_consort_modifier
					add = 20
				}

				modifier = { #More likely if not new consort
					NOT = {	has_character_flag = flag_new_consort }
					add = 25
				}

				modifier = { #More likely if they have a child
					any_child = {
						is_child_of = root
					}
					add = 15
				}

				modifier = { #More likely if it's the GC
					has_court_position = grand_consort_court_position
					add = 25
				}

				modifier = { #More likely if the consort is arrogant or greedy
					OR = {	
						has_trait = arrogant
						has_trait = greedy
					}
					add = 25
				}

				modifier = { #More likely if the consort is ambitious
					has_trait = ambitious
					add = 25
				}

				modifier = { #More likely if the consort doesn't accept concubinage
					is_concubine = yes
					hp_accepts_concubinage = no
					add = 15
				}
				modifier = { #More likely if they were forced into concubinage
					has_opinion_modifier = {
						modifier = forced_me_concubine_marriage_opinion
						target = root
					}
					add = 20
				}
			}
			save_scope_as = target_consort
		}
		scope:target_consort = {
			every_close_family_member = {
				limit = {
					harem_politics_valid_ruler_relative_trigger = yes
				}
				add_to_list = consort_relatives_list
			}
		}
		random_in_list = {
			list = consort_relatives_list
			weight = {
				base = 30

				modifier = { #Lieges won't stand a relative being a mere concubine
					is_liege_or_above_of = root
					add = 20
				}
				modifier = { #Powerful vassals
					OR = {
						is_powerful_vassal_of = root
						is_councillor_of = root
					}
					add = 15
				}
				modifier = { #Neighbors are more dangerous
					any_sub_realm_county = {
						is_neighbor_to_realm = root
					}
					add = 15
				}

				modifier = { #Superior won't beg to the weak
					max_military_strength < root.max_military_strength
					add = 10
				}

				modifier = { #Superior won't beg to the weak
					OR = {	
						is_powerful_vassal_of = root
						is_councillor_of = root
					}
					add = 15
				}

				modifier = { #Less likely if shy
					has_trait = shy
					add = -10
				}
				modifier = { #Less likely if craven
					has_trait = craven
					add = -10
				}
				
				modifier = { #More likely if brave
					has_trait = brave
					add = 10
				}
				modifier = { #More likely if ambitious and root has a high rank
					has_trait = ambitious
					root = {
						highest_held_title_tier >= tier_kingdom
					}
					add = 10
				}

				modifier = { #More likely if the consort doesn't accept concubinage
					scope:target_consort = {
						is_concubine = yes
					}
					hp_accepts_concubinage = no
					add = 25
				}

				modifier = { #Good relation to root
					has_relation_best_friend = root
					add = 15
				}
				modifier = { #Good relation to root
					has_relation_friend = root
					add = 10
				}
				modifier = { #Good relation to root
					has_relation_soulmate = root
					add = 15
				}
				modifier = { #Good relation to root
					has_relation_lover = root
					add = 10
				}

				modifier = { #Good relation to root
					has_relation_nemesis = root
					add = -20
				}
				modifier = { #Good relation to root
					has_relation_rival = root
					add = -10
				}
			}
			save_scope_as = sender
		}
	}

	option = { #Promote to GC
		name = harem_politics.0029.a
		trigger = {
			NOT = {
				employs_court_position = grand_consort_court_position
			}
			can_appoint_char_to_court_position = {
				CHAR = scope:target_consort
				COURT_POS = grand_consort_court_position
			}
			gold > 0
		}
		scope:sender = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 15
			}
			if = {
				limit = {
					is_vassal_of = root
				}
				add_faction_cooldown_effect = { YEARS = 4 }
			}
			else = {
				add_truce_both_ways = {
					character = root
					years = 4
					name = TRUCE_HAREM
				}
			}
		}
		appoint_court_position = {
			recipient = scope:target_consort
			court_position = grand_consort_court_position
		}

		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:target_consort
				multiplier = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:sender
				multiplier = 0.30
			}
			
			#Sender's consideration
			#Tier difference
			modifier = {
				scope:sender = {
					is_liege_or_above_of = root
				}
				add = 75
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value = 1
					}
				}
				add = 10
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < 0
					}
				}
				add = -5
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < -1
					}
				}
				add = -10
			}
			#Military difference
			modifier = {
				scope:sender = {
					max_military_strength > root.max_military_strength
				}
				add = 15
			}
			#Vassal power
			modifier = {
				scope:sender = {
					is_powerful_vassal_of = root
				}
				add = 15
			}
			modifier = {
				scope:sender = {
					is_councillor_of = root
				}
				add = 10
			}
			#Religious and cultural differences
			modifier = {
				scope:sender.culture = {
					this = root.culture
				}
				add = 10
			}
			modifier = {
				scope:sender.culture = {
					NOT = {
						this = root.culture
					}
					cultural_acceptance = { target = root.culture value >= hybridization_threshold_flat_number_value }
				}
				add = 10
			}
			modifier = {
				scope:sender.faith = {
					this = root.faith
				}
				add = 10
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_astray_level
					}
				}
				add = -5
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_hostile_level
					}
				}
				add = -5
			}
			#Relation to root
			modifier = { #Good relation to root
				has_relation_best_friend = scope:sender
				add = 15
			}
			modifier = { #Good relation to root
				has_relation_friend = scope:sender
				add = 10
			}
			modifier = { #Good relation to root
				has_relation_soulmate = scope:sender
				add = 15
			}
			modifier = { #Good relation to root
				has_relation_lover = scope:sender
				add = 10
			}

			#Consort's considerations
			#Children
			modifier = {
				scope:target_consort = {
					any_child = {
						is_child_of = root
					}
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					any_child = {
						is_player_heir_of = root
					}
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					any_child = {
						is_child_of = root
						character_gender_can_inherit_from_trigger = { CHARACTER = root }
					}
				}
				add = 5
			}
			#Relation and favor
			modifier = {
				scope:target_consort = {
					has_relation_lover = root
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_relation_soulmate = root
				}
				add = 20
			}
			modifier = {
				scope:target_consort = {
					has_relation_friend = root
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_relation_best_friend = root
				}
				add = 15
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			#Behavior in the harem
			modifier = {
				scope:target_consort = {
					harem_politics_evil_consort_trigger = no
				}
				add = 5
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = diplomatic_consort_modifier
				}
				add = 10
			}
			#Not new
			modifier = {
				scope:target_consort = {
					NOT = {
						has_character_flag = flag_new_consort
					}
				}
				add = 10
			}
			#Stress
			modifier = {
				has_trait = just
				OR = {
					has_imprisonment_reason = scope:target_consort
					scope:target_consort = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
				add = -15
			}
		}
	}

	option = { #Marry them
		name = harem_politics.0029.b
		trigger = {
			allowed_more_spouses = yes
			scope:target_consort = {
				is_concubine = yes
			}
		}
		create_alliance = {
			target = scope:sender
			allied_through_owner = root
			allied_through_target = scope:target_consort
		}
		scope:sender = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 25
			}
		}

		if = {
			limit = {
				has_trait = just
				OR = {
					has_imprisonment_reason = scope:target_consort
					scope:target_consort = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
			}
			stress_impact = {
				just = minor_stress_impact_gain
			}
		}
		if = {
			limit = {
				is_female = yes
			}
			marry_matrilineal = scope:target_consort
		}
		else = {
			marry = scope:target_consort
		}
		scope:target_consort = {
			save_scope_as = secondary_recipient
		}
		save_scope_as = actor
		save_scope_as = secondary_actor
		save_scope_as = recipient
		marriage_interaction_on_accept_effect = yes

		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:target_consort
				multiplier = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:sender
				multiplier = 0.30
			}
			
			#Sender's consideration
			#Tier difference
			modifier = {
				scope:sender = {
					is_liege_or_above_of = root
				}
				add = 100
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value > 0
					}
				}
				add = 15
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < 0
					}
				}
				add = -5
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < -1
					}
				}
				add = -10
			}
			#Military difference
			modifier = {
				scope:sender = {
					max_military_strength > root.max_military_strength
				}
				add = 20
			}
			#Vassal power
			modifier = {
				scope:sender = {
					is_powerful_vassal_of = root
				}
				add = 15
			}
			modifier = {
				scope:sender = {
					is_councillor_of = root
				}
				add = 10
			}
			#Religious and cultural differences
			modifier = {
				scope:sender.culture = {
					this = root.culture
				}
				add = 10
			}
			modifier = {
				scope:sender.culture = {
					NOT = {
						this = root.culture
					}
					cultural_acceptance = { target = root.culture value >= hybridization_threshold_flat_number_value }
				}
				add = 10
			}
			modifier = {
				scope:sender.faith = {
					this = root.faith
				}
				add = 10
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_astray_level
					}
				}
				add = -5
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_hostile_level
					}
				}
				add = -5
			}
			#Relation to root
			modifier = { #Good relation to root
				has_relation_best_friend = scope:sender
				add = 15
			}
			modifier = { #Good relation to root
				has_relation_friend = scope:sender
				add = 10
			}
			modifier = { #Good relation to root
				has_relation_soulmate = scope:sender
				add = 15
			}
			modifier = { #Good relation to root
				has_relation_lover = scope:sender
				add = 10
			}

			#Consort's considerations
			#Children
			modifier = {
				scope:target_consort = {
					any_child = {
						is_child_of = root
					}
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					any_child = {
						is_player_heir_of = root
					}
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					any_child = {
						is_child_of = root
						character_gender_can_inherit_from_trigger = { CHARACTER = root }
					}
				}
				add = 5
			}
			#Relation and favor
			modifier = {
				scope:target_consort = {
					has_relation_lover = root
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_relation_soulmate = root
				}
				add = 20
			}
			modifier = {
				scope:target_consort = {
					has_relation_friend = root
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_relation_best_friend = root
				}
				add = 15
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			#Behavior in the harem
			modifier = {
				scope:target_consort = {
					harem_politics_evil_consort_trigger = no
				}
				add = 15
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = diplomatic_consort_modifier
				}
				add = 10
			}
			#Not new
			modifier = {
				scope:target_consort = {
					NOT = {
						has_character_flag = flag_new_consort
					}
				}
				add = 10
			}
			#Stress
			modifier = {
				has_trait = just
				OR = {
					has_imprisonment_reason = scope:target_consort
					scope:target_consort = {
						any_secret = { 
							is_known_by = root
							is_criminal_for = secret_owner
						}
					}
				}
				add = -15
			}
			# Number of spouses
			modifier = {
				trigger_if = {
					limit = {
						primary_title.tier >= 5
					}
					any_spouse = {
						count < 4
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 4
					}
					any_spouse = {
						count < 3
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 3
					}
					any_spouse = {
						count < 2
					}
				}
				trigger_else = {
					any_spouse = {
						count < 1
					}
				}
				NOT = {
					has_government = landless_adventurer_government
				}
				add = 15
			}
		}
	}

	option = { #Nope
		name = harem_politics.0029.c

		scope:sender = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -25
			}
		}

		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:target_consort
				multiplier = -0.15
			}
			opinion_modifier = {
				opinion_target = scope:sender
				multiplier = -0.30
			}
			
			#Sender's consideration
			#Tier difference
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < 0
					}
				}
				add = 5
			}
			modifier = {
				scope:sender = {
					tier_difference = {
						target = root
						value < -1
					}
				}
				add = 10
			}
			#Military difference
			modifier = {
				scope:sender = {
					max_military_strength < root.max_military_strength
				}
				add = 10
			}
			#Claims
			modifier = {
				any_claim = {
					holder = scope:sender
				}
				add = 15
			}
			#Religious and cultural differences
			modifier = {
				scope:sender.culture = {
					NOT = {
						this = root.culture
					}
					cultural_acceptance = { target = root.culture value < hybridization_threshold_flat_number_value }
				}
				add = 10
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_astray_level
					}
				}
				add = 5
			}
			modifier = {
				faith = {
					faith_hostility_level = {
						target = scope:sender.faith
						value >= faith_hostile_level
					}
				}
				add = 10
			}
			#Relation to root
			modifier = {
				has_relation_rival = scope:sender
				add = 10
			}
			modifier = {
				has_relation_nemesis = scope:sender
				add = 20
			}

			#Consort's considerations
			#Relation and favor
			modifier = {
				scope:target_consort = {
					has_relation_rival = root
				}
				add = 10
			}
			modifier = {
				scope:target_consort = {
					has_relation_nemesis = root
				}
				add = 20
			}
			#Behavior in the harem
			modifier = {
				scope:target_consort = {
					harem_politics_evil_consort_trigger = yes
				}
				add = 5
			}
			modifier = {
				scope:target_consort = {
					has_character_modifier = scheming_consort_modifier
				}
				add = 5
			}
			#New
			modifier = {
				scope:target_consort = {
					has_character_flag = flag_new_consort
				}
				add = 10
			}
		}
	}

	after = {
		add_character_flag = {
			flag = had_ruler_consort_promotion_event_flag
			years = 4
		}
		scope:target_consort = {
			add_character_flag = {
				flag = flag_considered_consort
				years = 3
			}
		}
	}
}

#######################################################
##Choosing between a vassal's child or their servant##
#######################################################
scripted_trigger harem_politics_valid_vassal_child_trigger = {
	is_physically_able_ai_adult = yes
	is_travelling = no
	hp_accepts_harems = yes
	can_marry_character_trigger = {
		CHARACTER = root
	}
	is_hostage = no
	
	age <= 30
	any_consort = {
		count = 0
	}

	exists = court_owner
	court_owner = {
		NOT = {
			this = root
		}
		is_vassal_of = root
	}
	court_owner.primary_title = {
		place_in_line_of_succession = {
			target = prev
			value >= 3
		}
	}

	exists = dynasty
	NOR = {
		dynasty = root.dynasty

		any_former_concubinist = {
			this = root
		}
		any_former_spouse = {
			this = root
		}

		has_relation_rival = root
		has_relation_nemesis = root
		has_relation_friend = root
		has_relation_best_friend = root
		has_relation_lover = root
		has_relation_soulmate = root

		any_child = {
			is_child_of = root
		}

		has_trait = pregnant
		has_trait = eunuch
		has_trait = bastard

		exists = betrothed
	}

	num_of_good_genetic_traits = 0
}

scripted_trigger harem_politics_valid_vassal_trigger = {
	is_physically_able_ai_adult = yes
	is_travelling = no
	is_at_war = no
	is_vassal_of = root
	
	hp_accepts_harems = yes

	exists = dynasty
	NOR = {
		dynasty = root.dynasty
		has_relation_rival = root
		has_relation_nemesis = root

		has_hook = root

		government_has_flag = government_is_republic
		government_has_flag = government_is_theocracy
	}

	root = {
		NOT = {
			has_hook = prev
		}
	}
}

scripted_trigger harem_politics_valid_vassal_0030_trigger = {
	harem_politics_valid_vassal_trigger = yes
	hp_accepts_harems = yes
	opinion = {
		target = root
		value >= -15
	}
	any_child = {
		harem_politics_valid_vassal_child_trigger = yes
	}

	NOR = {
		has_relation_friend = root
		has_relation_best_friend = root
		has_relation_lover = root
		has_relation_soulmate = root

		is_allied_to = root

		has_trait = content
		has_trait = humble
		is_close_or_extended_family_of = root
	}
}

scripted_effect harem_politics_make_concubine_effect = {
	save_scope_as = actor
	save_scope_as = secondary_actor
	$CONSORT$ = {
		if = {
			limit = {
				root = {
					any_consort = {
						is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
						has_variable = favor
						count >= 3
					}
				}
			}
			set_variable = {
				name = favor
				value = initial_favor_valuation
			}
		}
		add_opinion = {
			target = root
			modifier = grateful_opinion
			opinion = 10
		}
		save_scope_as = recipient
	}
	concubine_on_accept_effect = yes
	make_concubine = scope:recipient
}

scripted_effect harem_politics_marriage_effect = {
	if = {
		limit = {
			is_female = yes
		}
		marry_matrilineal = $CONSORT$
	}
	else = {
		marry = $CONSORT$
	}
	$CONSORT$ = {
		save_scope_as = secondary_recipient
	}
	save_scope_as = actor
	save_scope_as = secondary_actor
	save_scope_as = recipient
	marriage_interaction_on_accept_effect = yes
}

harem_politics.0030 = {
	orphan = yes
	type = character_event
	title = harem_politics.0030.t
	desc = {
		desc = harem_politics.0030.start.desc
		first_valid = {
			triggered_desc = {#A faction's leader
				trigger = {
					scope:vassal = {
						is_a_faction_leader = yes
					}
				}
				desc = harem_politics.0030.leader.desc
			}
			triggered_desc = {#A powerful vassal
				trigger = {
					scope:vassal = {
						is_powerful_vassal = yes
					}
				}
				desc = harem_politics.0030.powerful_vassal.desc
			}
			triggered_desc = {#Faction member
				trigger = {
					scope:vassal = {
						is_a_faction_member = yes
					}
				}
				desc = harem_politics.0030.faction.desc
			}
			triggered_desc = {#Fallback
				desc = harem_politics.0030.fallback.desc
			}
		}
		desc = harem_politics.0030.mid.desc
		first_valid = {
			triggered_desc = {#Lady-in-waiting
				trigger = {
					scope:servant = {
						is_female = yes
					}
				}
				desc = harem_politics.0030.lady_in_waiting.desc
			}
			triggered_desc = {#Fallback
				desc = harem_politics.0030.chamberlain.desc
			}
		}
		desc = harem_politics.0030.end.desc
	}
	theme = realm
	
	right_portrait = { 	
		character = scope:vassal_child
		animation = personality_content
	}
	left_portrait = { 	
		character = scope:servant
		animation = flirtation_left
	}
	lower_center_portrait = {
		character = scope:vassal
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
		hp_accepts_harems = yes
		highest_held_title_tier >= tier_kingdom
		# Different scenarios
		trigger_if = { # The child is offered as a spouse
			limit = {
				OR = {
					religion = religion:islam_religion
					has_unsettled_government_trigger = yes
					hp_accepts_concubinage = no
					AND = {
						is_married = no
						is_betrothed = no
					}
				}
			}
			allowed_more_spouses = yes
		}
		trigger_else = { # The child is offered as a concubine
			hp_accepts_concubinage = yes
			allowed_more_concubines = yes
		}
		hp_accepts_harems = yes
		any_vassal = {
			count >= 4
		}
		any_vassal = {
			harem_politics_valid_vassal_0030_trigger = yes
		}
		NOR = {
			has_character_flag = had_vassal_consort_event_flag
			has_character_modifier = mourner_modifier
			has_trait_with_flag = can_not_marry
		}
		harem_politics_valid_event_county_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = { #Powerful vassals
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				is_powerful_vassal = yes
			}
		}
		modifier = { #Unfriendly vassals
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				opinion = {
					target = root
					value <= -15
				}
			}
		}

		modifier = { #Factions
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				is_a_faction_member = yes
			}
		}
		modifier = { #Factions
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				is_a_faction_leader = yes
			}
		}
		modifier = { #Factions
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				joined_faction = {
					faction_power >= faction_power_halfway_threshold
				}
			}
		}

		modifier = { #Bad children
			add = 0.15
			any_vassal = {
				harem_politics_valid_vassal_0030_trigger = yes
				any_child = {
					harem_politics_valid_vassal_child_trigger = yes
					num_of_bad_genetic_traits >= 1
				}
			}
		}
	}
	
	immediate = {
		save_scope_as = harem_liege

		# Let's see if both can be taken as consorts
		if = { # The child can be a spouse
			limit = {
				OR = {
					religion = religion:islam_religion
					has_unsettled_government_trigger = yes
					hp_accepts_concubinage = no
					AND = {
						is_married = no
						is_betrothed = no
					}
				}
				allowed_more_spouses = yes
			}
			# Check
		}
		else_if = { # The child can be a concubine
			limit = {
				hp_accepts_concubinage = yes
				allowed_more_concubines = yes
			}
			save_scope_value_as = {
				name = available_concubine_slots
				value = {
					add = max_number_of_concubines
					subtract = number_of_concubines
				}
			}
		}

		every_vassal = {
			limit = {
				harem_politics_valid_vassal_0030_trigger = yes
			}
			add_to_list = vassal_list
		}

		random_in_list = {
			list = vassal_list
			weight = {
				base = 10

				#Rank
				modifier = { #King
					highest_held_title_tier = tier_kingdom
					add = 15
				}
				modifier = { #Duke
					highest_held_title_tier = tier_duchy
					add = 10
				}
				modifier = { #Count
					highest_held_title_tier = tier_county
					add = 5
				}

				#Power
				modifier = {
					is_powerful_vassal = yes
					add = 15
				}
				modifier = {
					is_councillor_of = root
					add = 10
				}

				#Personality
				modifier = {
					has_trait = ambitious
					add = 10
				}
				modifier = {
					has_trait = greedy
					add = 10
				}
				modifier = {
					has_trait = arrogant
					add = 10
				}

				#Opinion
				opinion_modifier = {
					opinion_target = root
					multiplier = 0.15
				}

				#Factions
				modifier = { #Member
					is_a_faction_member = yes
					add = 10
				}
				modifier = { #Leader
					is_a_faction_leader = yes
					add = 10
				}
				modifier = { #Faction power
					joined_faction = {
						faction_power >= faction_power_halfway_threshold
					}
					add = 10
				}

				#Ugly kids
				modifier = { #One negative trait
					any_child = {
						harem_politics_valid_vassal_child_trigger = yes
						num_of_bad_genetic_traits >= 1
					}
					add = 5
				}
				modifier = { #Two negative traits
					any_child = {
						harem_politics_valid_vassal_child_trigger = yes
						num_of_bad_genetic_traits >= 2
					}
					add = 5
				}
			}
			save_scope_as = vassal
		}

		scope:vassal = {
			if = {
				limit = {
					is_a_faction_member = yes
				}
				joined_faction = {
					save_scope_as = faction # For loc
				}
			}
			random_child = {
				limit = {
					harem_politics_valid_vassal_child_trigger = yes
				}
				weight = {
					base = 10
					modifier = { #One negative trait
						num_of_bad_genetic_traits >= 1
						add = 10
					}
					modifier = { #One negative trait
						num_of_bad_genetic_traits >= 2
						add = 10
					}
					modifier = { #One negative trait
						num_of_bad_genetic_traits = 3
						add = 5
					}

					#Bad skills
					modifier = {
						diplomacy <= mediocre_skill_rating
						add = 10
					}
					modifier = {
						martial <= mediocre_skill_rating
						add = 5
					}
					modifier = {
						stewardship <= mediocre_skill_rating
						add = 10
					}
					modifier = {
						intrigue >= high_skill_rating
						add = 10
					}
					modifier = {
						intrigue >= very_high_skill_rating
						add = 10
					}
					modifier = {
						learning <= mediocre_skill_rating
						add = 5
					}
					
					modifier = { #Young consorts are more marriageable
						age <= {
							value = root.age
						}
						add = 15
					}
				}
				save_scope_as = vassal_child
			}
		}
		# Choose the reference location
		hp_select_concubine_location_effect = yes
		create_character = {
			location = root.capital_province
			template = pretty_servant_template
			gender_female_chance = {
				if = {
					limit = {
						scope:harem_liege = { allowed_to_marry_same_sex_trigger = yes }
					}
					add = 50
				}
				else_if = {
					limit = { scope:harem_liege = { is_female = yes } }
					add = 0
				}
				else = {
					add = 100
				}
			}
			save_scope_as = servant
		}
	}

	option = { #Take the vassal's child as a consort
        name = harem_politics.0030.a
		trigger = {
			OR = {
				AND = {
					hp_accepts_concubinage = yes
					allowed_more_concubines = yes
				}
				AND = {
					hp_accepts_concubinage = no
					allowed_more_spouses = yes
				}
			}
		}	
		
		if = {
			limit = {
				allowed_more_concubines = yes
			}
			harem_politics_make_concubine_effect = { CONSORT = scope:vassal_child }
			add_truce_both_ways = {
				character = scope:vassal
				years = 4
				name = TRUCE_HAREM
			}
		}
		else_if = {
			limit = {
				allowed_more_spouses = yes
			}
			harem_politics_marriage_effect = { CONSORT = scope:vassal_child }

			create_alliance = {
				target = scope:vassal
				allied_through_owner = root
				allied_through_target = scope:vassal_child
			}
		}

		scope:vassal = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 15
			}
		}

		stress_impact = {
			chaste = minor_stress_impact_gain
		}


        ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_honor = 0.10
				ai_vengefulness = -0.1
   			}
			modifier = { #Chaste
			   has_trait = chaste
			   add = -25
			}
			modifier = { #Consorts
				OR = {
					number_of_concubines < number_of_desired_concubines
					AND = {
						primary_title.tier >= 5
						any_spouse = {
							count < 4
						}
					}
					AND = {
						primary_title.tier >= 4
						any_spouse = {
							count < 3
						}
					}
				}
			   add = 10
			}

			modifier = { #Powerful vassal
				scope:vassal = {
					is_powerful_vassal = yes
				}
				add = 10
			}
			modifier = { #Councilor
				scope:vassal = {
					is_councillor_of = root
				}
				add = 10
			}

			modifier = { #Factions
				scope:vassal = {
					is_a_faction_member = yes
				}
				add = 10
			}
			modifier = { #Factions
				scope:vassal = {
					is_a_faction_leader = yes
				}
				add = 10
			}
			modifier = { #Factions
				scope:vassal = {
					joined_faction = {
						faction_power >= faction_power_halfway_threshold
					}
				}
				add = 10
			}

			modifier = { #Traits
				scope:vassal_child = {
					num_of_bad_genetic_traits >= 1
				}
				add = -5
			}
			modifier = { #Traits
				scope:vassal_child = {
					num_of_bad_genetic_traits >= 2
				}
				add = -5
			}
			modifier = { #Traits
				scope:vassal_child = {
					num_of_bad_genetic_traits >= 3
				}
				add = -5
			}

			modifier = { #Skills
				scope:vassal_child = {
					diplomacy >= medium_skill_rating
				}
				add = 10
			}
			modifier = { #Skills
				scope:vassal_child = {
					diplomacy >= high_skill_rating
				}
				add = 10
			}
			modifier = { #Skills
				scope:vassal_child = {
					diplomacy >= very_high_skill_rating
				}
				add = 5
			}

			modifier = { #Skills
				scope:vassal_child = {
					diplomacy <= mediocre_skill_rating
				}
				add = -10
			}
			modifier = { #Skills
				scope:vassal_child = {
					stewardship <= mediocre_skill_rating
				}
				add = -5
			}
			modifier = { #Skills
				scope:vassal_child = {
					learning <= mediocre_skill_rating
				}
				add = -5
			}

			#Personality
			compatibility_modifier = {
				compatibility_target = scope:vassal_child
				multiplier = 1
				min = -15
				max = 15
			}

			modifier = {
				is_attracted_to_gender_of = scope:vassal_child
				add = 10
			}
        }
    }

	option = { #Take the vassal's child's servant as a consort
        name = harem_politics.0030.b
		trigger = {
			OR = {
				AND = {
					hp_accepts_concubinage = yes
					allowed_more_concubines = yes
				}
				AND = {
					hp_accepts_concubinage = no
					allowed_more_spouses = yes
				}
			}
		}	
		
		if = {
			limit = {
				allowed_more_concubines = yes
			}
			harem_politics_make_concubine_effect = { CONSORT = scope:servant }
		}
		else_if = {
			limit = {
				allowed_more_spouses = yes
			}
			harem_politics_marriage_effect = { CONSORT = scope:servant }
		}

		scope:vassal = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -25
			}

			if = {
				limit = {
					is_a_faction_leader = yes
				}
				joined_faction = {
					add_faction_discontent = 20
				}
			}
			else_if = {
				limit = {
					is_a_faction_member = yes
				}
				joined_faction = {
					add_faction_discontent = 10
				}
			}
		}
		
		scope:vassal_child = {
			add_opinion = {
				target = root
				modifier = rejected_me_opinion
			}
		}

		stress_impact = {
			chaste = minor_stress_impact_gain
		}


        ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_honor = -0.10
				ai_vengefulness = 0.1
   			}
			modifier = { #Chaste
			   has_trait = chaste
			   add = -25
			}
			modifier = { #Consorts
				OR = {
					number_of_concubines < number_of_desired_concubines
					AND = {
						primary_title.tier >= 5
						any_spouse = {
							count < 4
						}
					}
					AND = {
						primary_title.tier >= 4
						any_spouse = {
							count < 3
						}
					}
				}
			   add = 10
			}

			modifier = { #Powerful vassal
				scope:vassal = {
					is_powerful_vassal = no
				}
				add = 10
			}
			modifier = { #Councilor
				scope:vassal = {
					is_councillor_of = root
				}
				add = 5
			}

			modifier = { #Rank
				scope:vassal = {
					highest_held_title_tier = tier_county
				}
				add = 5
			}
			modifier = { #Rank
				scope:vassal = {
					highest_held_title_tier = tier_barony
				}
				add = 10
			}

			modifier = { #Factions
				scope:vassal = {
					is_a_faction_member = yes
				}
				add = -5
			}
			modifier = { #Factions
				scope:vassal = {
					is_a_faction_leader = yes
				}
				add = -5
			}
			modifier = { #Factions
				scope:vassal = {
					joined_faction = {
						faction_power >= faction_power_halfway_threshold
					}
				}
				add = -15
			}

			#Personality
			compatibility_modifier = {
				compatibility_target = scope:servant
				multiplier = 1
				min = -15
				max = 15
			}

			#Opinion
			opinion_modifier = {
				opinion_target = scope:servant
				multiplier = 0.15
			}
			opinion_modifier = { #More likely if this vassal hates us
				who = scope:vassal
				opinion_target = root
				min = -25
				max = 15
				multiplier = -0.25
			}

			#Traits
			modifier = {
				scope:servant = {
					has_trait = beauty_good_2
				}
				add = 5
			}
			modifier = {
				scope:servant = {
					has_trait = beauty_good_3
				}
				add = 10
			}
			modifier = {
				scope:servant = {
					num_of_good_genetic_traits > 1
				}
				add = 10
			}
			modifier = {
				is_attracted_to_gender_of = scope:servant
				add = 10
			}
        }
    }

	option = { #Refuse them both
        name = harem_politics.0030.c

		scope:vassal = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -10
			}

			if = {
				limit = {
					is_a_faction_leader = yes
				}
				joined_faction = {
					add_faction_discontent = 10
				}
			}
			else_if = {
				limit = {
					is_a_faction_member = yes
				}
				joined_faction = {
					add_faction_discontent = 5
				}
			}
		}
		
		scope:vassal_child = {
			add_opinion = {
				target = root
				modifier = rejected_me_opinion
			}
		}

		stress_impact = {
			lustful = minor_stress_impact_gain
		}

        ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_honor = -0.10
				ai_vengefulness = 0.1
   			}

			modifier = { #Lustful
			   has_trait = lustful
			   add = -25
			}
			modifier = { #Consorts
				OR = {
					number_of_concubines < number_of_desired_concubines
					AND = {
						primary_title.tier >= 5
						any_spouse = {
							count < 4
						}
					}
					AND = {
						primary_title.tier >= 4
						any_spouse = {
							count < 3
						}
					}
				}
			   add = -10
			}

			modifier = { #Powerful vassal
				scope:vassal = {
					is_powerful_vassal = yes
				}
				add = -5
			}

			modifier = { #Rank
				scope:vassal = {
					highest_held_title_tier = tier_county
				}
				add = 5
			}
			modifier = { #Rank
				scope:vassal = {
					highest_held_title_tier = tier_barony
				}
				add = 10
			}

			modifier = {
				NOT = { is_attracted_to_gender_of = scope:vassal_child }
				add = 5
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:servant }
				add = 10
			}

			modifier = {
				add = 15
				has_sexuality = asexual
			}
        }
    }

	after = {
		add_character_flag = {
			flag = had_vassal_consort_event_flag
			years = 5
		}
		hidden_effect = {
			if = {
				limit = {
					scope:servant = {
						NOT = {
							is_consort_of = root
						}
					}
				}
				scope:servant = {
					death = {
						death_reason = death_vanished
					}
				}
			}
		}
	}
}

############################################
##A consort asks you to promote a relative##
############################################
scripted_trigger harem_politics_valid_consort_landed_relative_trigger = {
	harem_politics_valid_vassal_trigger = yes

	OR = {	
		AND = { #Promote count to duke
			highest_held_title_tier = tier_county
			any_held_title = { #Not many titles
				tier = tier_county
				count <= 3
			}
			primary_title = {
				de_jure_liege = {
					OR = {
						holder ?= {
							this = root
							any_held_title = {
								tier = tier_duchy
								is_head_of_faith = no
								is_noble_family_title = no
								count >= 2
							}
						}
						AND = {
							is_title_created = no
							any_in_de_jure_hierarchy = {
								filter = {
									tier = tier_county
								}
								holder ?= {
									OR = {
										this = root
										is_vassal_or_below_of = root
									}
								}
								percent >= 0.50
							}
							root = {
								gold >= create_duchy_title_value_harem_politics
							}
						}
					}
					NOT = {
						any_de_jure_county = {
							this = root.capital_county
						}
					}
				}
			}	
			root = {
				highest_held_title_tier >= tier_kingdom
			}
		}
		AND = {	#Promote baron to count
			highest_held_title_tier = tier_barony
			primary_title = {
				de_jure_liege = {
					NOT = {
						this = root.capital_county
					}
				}
			}	
			root = {
				any_held_title = {
					tier = tier_county
					count >= 4
				}
				highest_held_title_tier >= tier_duchy
			}
		}
	}
}

scripted_trigger harem_politics_valid_consort_0031_trigger = {
	harem_politics_ambitious_consort_trigger = yes
	any_close_family_member = {
		harem_politics_valid_consort_landed_relative_trigger = yes
	}
}

scripted_effect harem_politics_create_or_grant_title_effect = {
	ROOT = {
		if = {
			limit = {
				scope:consort_relative = {
					primary_title = {
						de_jure_liege = {
							is_title_created = no
							any_in_de_jure_hierarchy = {
								filter = {
									tier = tier_county
								}
								holder ?= {
									OR = {
										this = root
										is_vassal_or_below_of = root
									}
								}
								percent >= 0.50
							}
						}
					}
				}
			}
			#Subtract some money
			remove_short_term_gold = create_duchy_title_value_harem_politics
		}
		else_if = {
			limit = {
				scope:consort_relative = {
					primary_title = {
						de_jure_liege = {
							holder ?= root
						}
					}
				}
			}
			#Nothing
		}
		create_title_and_vassal_change = {
			type = granted
			save_scope_as = change
			add_claim_on_loss = no
		}
		$TITLE$ = {
			change_title_holder = {
				holder = scope:consort_relative
				change = scope:change
			}
			if = {
				limit = {
					tier = tier_duchy
				}
				#If the holder has other associated titles, they're given as well
				if = {
					limit = {
						any_in_de_jure_hierarchy = {
							tier = tier_county
							holder ?= root
						}
					}
					every_in_de_jure_hierarchy = {
						limit = {
							tier = tier_county
							holder ?= root
						}
						change_title_holder = {
							holder = scope:consort_relative
							change = scope:change
						}
					}
					scope:consort_relative = {
						add_opinion = {
							target = ROOT
							modifier = received_title_county
						}
					}
				}
				#If the holder is root's vassal, the vassal is also transferred
				if = {
					limit = {
						any_in_de_jure_hierarchy = {
							tier = tier_county
							exists = holder
							holder = {
								is_vassal_of = root
								NOT = { this = scope:consort_relative }
								primary_title = {
									de_jure_liege = {
										this = $TITLE$
									}
								}
							}
						}
					}
					every_in_de_jure_hierarchy = {
						limit = {
							tier = tier_county
							exists = holder
							holder = {
								is_vassal_of = root
								NOT = { this = scope:consort_relative }
								primary_title = {
									de_jure_liege = {
										this = $TITLE$
									}
								}
							}
						}
						holder = {
							change_liege = {
								liege = scope:consort_relative
								change = scope:change
							}
						}
					}
					scope:consort_relative = {
						add_opinion = {
							target = root
							modifier = granted_vassal
						}
					}
				}
			}
		}
		resolve_title_and_vassal_change = scope:change
		scope:consort_relative = {
			if = {
				limit = { $TITLE$.tier = tier_county }
				add_opinion = {
					target = ROOT
					modifier = received_title_county
				}
			}
			else = {
				add_opinion = {
					target = ROOT
					modifier = received_title_duchy
				}
			}
			if = {
				limit = {
					is_ai = no
				}
				hidden_effect = {
					send_interface_toast = {
						type = event_generic_good
						title = helpful_consort_title
						right_icon = scope:harem_liege
						left_icon = scope:meddling_relative
			
						show_as_tooltip = {
							scope:harem_liege = {
								create_title_and_vassal_change = {
									type = granted
									save_scope_as = change
									add_claim_on_loss = no
								}
								$TITLE$ = {
									change_title_holder = {
										holder = scope:consort_relative
										change = scope:change
									}
								}
								resolve_title_and_vassal_change = scope:change
							}
						}
					}
				}
			}
		}
		if = {
			limit = {
				can_add_hook = {
					target = scope:consort_relative
					type = indebted_hook
				}
			}
			add_hook = {
				target = scope:consort_relative
				type = indebted_hook
			}
		}
	}
}

harem_politics.0031 = {
	type = character_event
	title = harem_politics.0031.t
	desc = harem_politics.0031.desc
	theme = realm
	override_background = {
		reference = study
	}
	
	right_portrait = { 	
		character = root
		animation = worry
	}
	left_portrait = {
		character = scope:meddling_relative
		animation = sadness
	}
	lower_center_portrait = {
		character = scope:consort_relative
	}
	
	trigger = {
		is_physically_able_adult = yes
		is_at_war = no
		is_landed = yes
		hp_accepts_harems = yes
		highest_held_title_tier >= tier_kingdom
		
		NOR = {
        	has_character_flag = had_ambitious_consort_flag
	    }

		any_courtier = {
			harem_politics_valid_consort_0031_trigger = yes
		}
		gold > 0
	}

	weight_multiplier = {
		base = 1
		modifier = { #Many duchies
			add = 0.2
			any_held_title = {
				tier = tier_duchy
				is_head_of_faith = no
				is_noble_family_title = no
				count >= 3
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 6
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 7
			}
		}
		modifier = { #Many counties
			add = 0.1
			any_held_title = {
				tier = tier_county
				count >= 8
			}
		}
		modifier = { #To make things interesting to generous characters
			add = 0.20
			has_trait = generous
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.2
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_courtier = {
			limit = {
				harem_politics_valid_consort_0031_trigger = yes
			}
			add_to_list = requester_list
		}
		random_in_list = {
			list = requester_list
			weight = {
				base = 10
				modifier = { #The main spouse
					this = root.primary_spouse
					add = 20
				}
				modifier = { #The Empress Dowager
					any_child = {
						this = root
					}
					add = 20
				}
				modifier = { #Grand Consort
					has_court_position = grand_consort_court_position
					add = 15
				}
				modifier = { #Spouses rank higher
					is_spouse_of = root
					add = 10
				}
				modifier = { #Soulmate
					has_relation_soulmate = root
					add = 50
				}
				modifier = { #Lover
					has_relation_lover = root
					add = 25
				}
				modifier = { #BFF
					has_relation_best_friend = root
					add = 20
				}
				modifier = { #Friends
					has_relation_friend = root
					add = 10
				}
				modifier = { #Favored consort
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				modifier = { #Favored consort
					has_character_modifier = beloved_consort_modifier
					add = 25
				}
				modifier = { #Favored consort
					has_character_modifier = favor_boost_modifier
					add = 10
				}
				modifier = { #Good contacts
					any_child = {
						is_child_of = root
						count >= 3
					}
					add = 10
				}
				
				modifier = { #Faith
					faith = root.faith
					add = 10
				}
				modifier = { #Culture
					culture = root.culture
					add = 10
				}

				modifier = { #Traits
					has_trait = greedy
					add = 10
				}
				modifier = { #Traits
					has_trait = ambitious
					add = 10
				}
				modifier = { #Traits
					has_trait = arrogant
					add = 10
				}
				modifier = { #Traits
					has_trait = impatient
					add = 10
				}
				modifier = { #Traits
					has_trait = deceitful
					add = 5
				}
			}
			save_scope_as = meddling_relative
		}

		scope:meddling_relative = {
			every_close_family_member = {
				limit = {
					harem_politics_valid_consort_landed_relative_trigger = yes
				}
				add_to_list = valid_relative_list
			}
			random_in_list = {
				list = valid_relative_list
				weight = {
					base = 10
					modifier = { #Siblings are priority
						any_close_family_member = { this = scope:meddling_relative }
						add = 25
					}
					modifier = { #Parents event more
						any_child = {
							this = scope:meddling_relative
						}
						add = 15
					}
					modifier = { #Same dynasty
						exists = dynasty
						exists = scope:meddling_relative.dynasty
						dynasty = scope:meddling_relative.dynasty
						add = 20
					}
					modifier = { #Same house
						exists = house
						exists = scope:meddling_relative.house
						house = scope:meddling_relative.house
						add = 15
					}
					modifier = { #Opinion
						opinion = {
							target = scope:meddling_relative
							value >= low_positive_opinion
						}
						add = 20
					}
					modifier = { #Martial
						martial >= very_high_skill_rating
						add = 25
					}
					modifier = { #Stewardship
						stewardship >= very_high_skill_rating
						add = 25
					}
					modifier = { #Martial
						martial >= high_skill_rating
						add = 15
					}
					modifier = { #Stewardship
						stewardship >= high_skill_rating
						add = 15
					}
					modifier = { #Martial
						martial >= decent_skill_rating
						add = 5
					}
					modifier = { #stewardship
						stewardship >= decent_skill_rating
						add = 5
					}
				}
				save_scope_as = consort_relative
			}
		}

		scope:consort_relative = {

			primary_title = {
				de_jure_liege = {
					save_scope_as = gift_title
				}
			}
		}
	}

	option = { #Give title away
        name = harem_politics.0031.a
		scope:meddling_relative = {
			calyver_favor_big_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
			add_character_flag = {
				flag = requested_favor_flag
				years = 3
			}
        }
		hidden_effect = {
			every_consort = {
				limit = {
					AND = {
						NOR = {
							this = scope:meddling_relative
							any_close_or_extended_family_member = {
								this = scope:meddling_relative
							}
							has_relation_best_friend = scope:meddling_relative
							has_relation_friend = scope:meddling_relative
							has_relation_lover = scope:meddling_relative
							has_relation_soulmate = scope:meddling_relative
						}
						harem_politics_evil_consort_trigger = yes
					}
				}
				add_opinion = {
					target = scope:meddling_relative
					modifier = envy_consort_opinion
				}
			}
			scope:consort_relative = {
				add_opinion = {
					target = scope:meddling_relative
					modifier = grateful_opinion
					opinion = 40
				}
			}
		}
		send_interface_toast = {
			left_icon = scope:consort_relative
			title = harem_politics.0008.a.tt
			harem_politics_create_or_grant_title_effect = { TITLE = scope:gift_title }
		}
		if = { #Stress gains unless you are over your domain limit
			limit = {
				OR = {
					AND = {
						scope:gift_title.tier = tier_duchy
						any_held_title = {
							tier = tier_duchy
							is_head_of_faith = no
							is_noble_family_title = no
							count <= 2
						}
					}
					AND = {
						scope:gift_title.tier = tier_county
						domain_size <= domain_limit
					}
				}
			}
			stress_impact = {
				greedy = medium_stress_impact_gain # But, titles
				diligent = medium_stress_impact_gain # But, I like managing stuff
				arrogant = medium_stress_impact_gain # But, my titles
			}
		}
		stress_impact = {
			lazy = minor_stress_impact_loss
			generous = minor_stress_impact_loss
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.5
   				ai_greed = -1
   			}
			modifier = { # Less likely if the title is a duchy with good buildings
				add = -20
				scope:gift_title = { 
					any_county_province = { has_special_building = yes }
				}
			}
            modifier = { # Weight up for family members.
            	add = 15
            	scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= low_positive_opinion
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= 50
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 5
            	opinion = {
            		target = scope:consort_relative
            		value >= 50
            	}
            }
			modifier = { #Fertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count >= 3
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_close_or_extended_family_member = {
						OR = {
							this = root.primary_spouse
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				exists = root.primary_spouse
				scope:meddling_relative = {
					this = root.primary_spouse
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = 5
			}

			modifier = { #Martial
				scope:consort_relative = {
					martial >= very_high_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship >= very_high_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial >= high_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship >= high_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial >= decent_skill_rating
				}
				add = 5
			}
			modifier = { #stewardship
				scope:consort_relative = {
					stewardship >= decent_skill_rating
				}
				add = 5
			}

            modifier = {	#Weight down for stress.
				add = -25
				has_trait = greedy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = diligent
			}
			modifier = {	#Weight down for stress.
				add = 15
				has_trait = humble
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = lazy
			}
			modifier = {	#Weight down for stress.
				add = 25
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favor_boost_modifier
				}
				add = 5
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root
					}
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root.primary_heir
					}
				}
				add = 10
			}
        }
    }

	option = { # Compromise - give them gold
        name = harem_politics.0031.b
		trigger = {
			gold >= minor_gold_value
		}
		show_as_unavailable = { NOT = { gold >= minor_gold_value } }
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= minor_gold_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		save_scope_value_as = {
			name = gold_to_pay
			value = minor_gold_value
		}
		pay_short_term_gold = {
			target = scope:consort_relative
			gold = scope:gold_to_pay
		}
		scope:consort_relative = {
			add_opinion = {
				target = scope:meddling_relative
				modifier = grateful_opinion
				opinion = 10
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
			if = {
				limit = {
					is_ai = no
				}
				send_interface_toast = {
					type = event_generic_good
					title = helpful_consort_title
					right_icon = scope:harem_liege
					left_icon = scope:meddling_relative
		
					show_as_tooltip = {
						scope:harem_liege = {
							pay_short_term_gold = {
								target = scope:consort_relative
								gold = scope:gold_to_pay
							}
						}
					}
				}
			}
		}
        scope:meddling_relative = {
			calyver_favor_moderate_gain_effect = yes
        	add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
			add_character_flag = {
				flag = requested_favor_flag
				years = 2
			}
        }
		hidden_effect = {
			every_consort = {
				limit = {
					AND = {
						NOR = {
							this = scope:meddling_relative
							any_close_or_extended_family_member = {
								this = scope:meddling_relative
							}
							has_relation_best_friend = scope:meddling_relative
							has_relation_friend = scope:meddling_relative
							has_relation_lover = scope:meddling_relative
							has_relation_soulmate = scope:meddling_relative
						}
						harem_politics_evil_consort_trigger = yes
					}
				}
				add_opinion = {
					target = scope:meddling_relative
					modifier = envy_consort_opinion
					opinion = -5
				}
			}
		}
        stress_impact = {
			greedy = medium_stress_impact_gain # But, titles
			arrogant = medium_stress_impact_gain # But, my titles
			generous = minor_stress_impact_loss
		}
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_rationality = 0.75
   				ai_greed = -0.5
   			}
			modifier = {
				gold <= medium_gold_value
				add = -15
			}
            modifier = { # Weight up for family members.
            	add = 15
            	scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= low_positive_opinion
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value >= 50
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 5
            	opinion = {
            		target = scope:consort_relative
            		value >= 50
            	}
            }
			modifier = { #Fertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count >= 3
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_close_or_extended_family_member = {
						OR = {
							this = root.primary_spouse
							is_powerful_vassal_of = root
							is_councillor_of = root
							is_parent_of = root
							is_liege_or_above_of = root
						}
					}
				}
				add = 5
			}
			modifier = { #Influential consort
				exists = root.primary_spouse
				scope:meddling_relative = {
					this = root.primary_spouse
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = 5
			}

            modifier = {	#Weight down for stress.
				add = -15
				has_trait = greedy
			}
			modifier = {	#Weight down for stress.
				add = 20
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -15
				has_trait = arrogant
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 10
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					has_character_modifier = favor_boost_modifier
				}
				add = 5
			}
			
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root
					}
				}
				add = 15
			}
			modifier = { #Influential consort
				scope:meddling_relative = {
					any_child = {
						this = root.primary_heir
					}
				}
				add = 15
			}
        }
    }

	option = { # You get nothing!
        name = harem_politics.0031.c
        scope:meddling_relative = {
			calyver_favor_minor_loss_effect = yes
        	add_opinion = {
        		target = ROOT
        		modifier = annoyed_opinion
        		opinion = -15
        	}
			add_character_flag = {
				flag = requested_favor_flag
				years = 5
			}
        }
        stress_impact = {
        	generous = medium_stress_impact_gain # But I have so much to give
        	lazy = medium_stress_impact_gain # I would rather have someone else do it
        	humble = medium_stress_impact_gain # Who am I to deny them?
        }
        ai_chance = {
            base = 100
            ai_value_modifier = {
   				ai_boldness = 1
   				ai_greed = 1
				ai_honor = 0.1
   			}
			modifier = {
				gold <= medium_gold_value
				add = 15
			}
            modifier = { # Weight up for NO family members.
            	add = 15
            	NOT = {
            		scope:consort_relative = { is_close_or_extended_family_of = ROOT }
            	}
            }
           modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:meddling_relative
            		value <= 0
            	}
            }
            modifier = { # Weight up for opinion.
            	add = 20
            	opinion = {
            		target = scope:meddling_relative
            		value <= 20
            	}
            }
			modifier = { # Weight up for opinion.
            	add = 10
            	opinion = {
            		target = scope:consort_relative
            		value <= 20
            	}
            }
			modifier = { #Non-influential consort
				scope:meddling_relative = {
					is_concubine_of = root
				}
				add = 20
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial <= mediocre_skill_rating
				}
				add = 5
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship <= mediocre_skill_rating
				}
				add = 5
			}
			modifier = { #Martial
				scope:consort_relative = {
					martial <= low_skill_rating
				}
				add = 10
			}
			modifier = { #Stewardship
				scope:consort_relative = {
					stewardship <= low_skill_rating
				}
				add = 10
			}
			modifier = {	#Weight down for stress.
				scope:consort_relative = {
					OR = {
						AND = {
							has_trait = witch
							trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = sodomite
							trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = fornicator
							trait_is_criminal_in_faith_trigger = { TRAIT = fornicator FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = adulterer
							trait_is_criminal_in_faith_trigger = { TRAIT = adulterer FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = incestuous
							trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = kinslayer_1
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_1 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = kinslayer_2
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_2 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = kinslayer_3
							trait_is_criminal_in_faith_trigger = { TRAIT = kinslayer_3 FAITH = root.faith GENDER_CHARACTER = scope:sinful_spouse }
						}
						AND = {
							has_trait = deviant
							trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
						AND = {
							has_trait = cannibal
							trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = scope:consort_relative }
						}
					}
				}
				add = 20
			}
            modifier = {	#Weight down for stress.
				add = -25
				has_trait = generous
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = lazy
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = humble
			}
			modifier = { #Infertile consort
				scope:meddling_relative = {
					any_child = {
						is_child_of = root
						count = 0
					}
				}
				add = 10
			}
        }
    }

	after = {
		add_character_flag = {
			flag = had_ambitious_consort_flag
			years = 5
		}
	}
}

#########################
##Meeting Concubine Mei##
#########################
scripted_trigger harem_politics_hui_gui_fei_trigger = {
	is_physically_able_ai = yes

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no

	harem_politics_evil_consort_trigger = yes

	is_courtier_of = root
	OR = {
		has_relation_best_friend = root
		has_relation_friend = root
		has_relation_lover = root
		has_relation_soulmate = root
		
		is_spouse_of = root
		has_court_position = grand_consort_court_position

		harem_politics_favored_consort_trigger = yes
	}
	NOR = { 
		has_opinion_modifier = {
			target = root
			modifier = forced_me_concubine_marriage_opinion
		}
		
		has_trait = ill
		has_trait = wounded
		has_trait = shy
		has_trait = craven

		has_trait = pregnant
	}
	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

harem_politics.0032 = {
	type = character_event
	title = harem_politics.0032.t
	desc = harem_politics.0032.desc
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = scope:mei_pin
		animation = flirtation_left
	}
	right_portrait = {
		character = root
		animation = personality_rational
	}
	lower_center_portrait = {
		character = scope:hui_gui_fei
	}
	
	trigger = {
		hp_accepts_concubinage = yes
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			is_imprisoned = no
			count >= 3
		}
		any_consort = {
			harem_politics_hui_gui_fei_trigger = yes
		}
		NOR = {
        	any_consort = {
	        	has_character_flag = flag_mei
	        }
			has_character_flag = met_mei_pin
			has_trait = shy
			has_trait = craven
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
	    }
		allowed_more_concubines = yes
		is_available_healthy_adult = yes
		is_available_at_peace_adult = yes
		highest_held_title_tier >= tier_kingdom
		trigger_if = {
			limit = {
				has_ep1_dlc_trigger = yes
			}
			trigger_if = {
				limit = {
					NOT = {
						government_has_flag = government_is_tribal
					}
				}
				has_royal_court = yes
				amenity_level = {
					type = court_servants
					value >= 3
				}
			}
			trigger_else = {
				government_has_flag = government_is_tribal
			}
		}
		trigger_else = {
			has_ep1_dlc_trigger = no
		}
		harem_politics_valid_event_county_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = -0.5
			has_trait = chaste
		}
		modifier = {
			add = 0.2
			has_trait = lustful
		}
		modifier = {
			add = 0.2
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.4
			age >= 45
		}
		modifier = { #Stress
			add = 0.1
			stress_level >= 1
		}
		modifier = { #Stress
			add = 0.1
			stress_level >= 2
		}
		modifier = {
			number_of_concubines < number_of_desired_concubines
			add = 0.1
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.2
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = { #Find Hui
			limit = {
				harem_politics_hui_gui_fei_trigger = yes
			}
			add_to_list = gui_fei_list
		}
		
		random_in_list = {
			list = gui_fei_list
			weight = {
				base = 10
				
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = beloved_consort_modifier
					add = 20
				}
				modifier = {
					has_character_modifier = favor_boost_modifier
					add = 15
				}

				modifier = {
					add = diplomacy
				}
				modifier = {
					add = learning
				}
				modifier = {
					has_trait = poet
					add = 15
				}

				modifier = {
					has_trait = beauty_good
					add = 5
				}
				modifier = {
					has_trait = beauty_good_2
					add = 5
				}
				modifier = {
					has_trait = beauty_good_3
					add = 10
				}
				
				modifier = {
					has_court_position = grand_consort_court_position
					add = 20
				}
				modifier = {
					is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
					add = 15
				}
			}
			save_scope_as = hui_gui_fei
		}
		# Choose the reference location
		hp_select_concubine_location_effect = yes
		#Create Mei
		hp_character_creation_effect = {
			CHARACTER = mei_pin
		}
		stress_impact = {
			base = minor_stress_loss
		}
	}
	
	option = { #Take Mei as a concubine
        name = harem_politics.0032.a
		trigger = {
			allowed_more_concubines = yes
		}
		take_special_concubine_event_with_other_consort_effect = {
			RECIPIENT = scope:mei_pin
			CURRENT_CONSORT = scope:hui_gui_fei
			FLAG = mei
		}
		had_sex_with_effect = {
			CHARACTER = scope:mei_pin
			PREGNANCY_CHANCE = pregnancy_chance
		}
		hidden_effect = {
			every_consort = { #Consorts think Mei used low tricks to seduce root
				limit = {
					NOR = {
						this = scope:mei_pin
						this = scope:hui_gui_fei
						has_opinion_modifier = {
							modifier = forced_me_concubine_marriage_opinion
							target = root
						}
					}
					harem_politics_evil_consort_trigger = yes
					hp_accepts_harems = yes
					is_courtier_of = root
				}
				add_opinion = {
					target = scope:mei_pin
					modifier = hatred_spouse_opinion
					opinion = -5
				}
			}

			#Trigger Mei's event
			if = {
				limit = {
					NOR = { 
						has_character_flag = had_mei_event_flag 
						has_character_flag = has_consort_event_flag 
					}
					any_consort = {
						age >= 27
						OR = {
							has_court_position = grand_consort_court_position
							is_married = yes
						}
						is_courtier_of = root
						harem_politics_evil_consort_trigger = yes
					}
				}
				random_consort = {
					limit = {
						age >= 27
						OR = {
							has_court_position = grand_consort_court_position
							is_married = yes
						}
						is_courtier_of = root
						harem_politics_evil_consort_trigger = yes
					}
					trigger_event = {
						id = consort_events.0001
						days = { 10 24 }
					}
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain 
			arrogant = minor_stress_impact_gain 
			paranoid = minor_stress_impact_gain 
		}
        ai_chance = {
            base = 50
            ai_value_modifier = {
				ai_honor = -0.05
				ai_boldness = 0.1
				ai_greed = 0.1
				ai_rationality = -0.1
   			}
			opinion_modifier = {
				opinion_target = scope:mei_pin
				min = -15
				max = 15
				multiplier = 0.15
			}
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:mei_pin
				min = -20
				max = 20
				multiplier = 2
			}

            modifier = {	#Weight up for stress.
				add = 20
				has_trait = lustful
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = paranoid
			}
			modifier = {	#Weight down for stress.
				add = -25
				has_trait = arrogant
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:mei_pin } }
				factor = 0
			}
        }
    }
	
	option = { # Enjoy time with Hui
        name = harem_politics.0032.b
		had_sex_with_effect = {
			CHARACTER = scope:hui_gui_fei
			PREGNANCY_CHANCE = pregnancy_chance
		}
        scope:hui_gui_fei = {
			calyver_favor_minor_gain_effect = yes
			if = {
				limit = {
					NOR = {
						has_relation_lover = root
						has_relation_soulmate = root
						has_relation_potential_lover = root
					}
				}
				set_relation_potential_lover = root
			}
        }
        stress_impact = {
        	chaste = minor_stress_impact_gain
        }
        ai_chance = {
            base = 50
            ai_value_modifier = {
   				ai_rationality = 0.1
				ai_honor = 0.1
				ai_boldness = -0.05
				ai_greed = -0.05
   			}
			opinion_modifier = {
			   opinion_target = scope:hui_gui_fei
			   min = -15
			   max = 15
			   multiplier = 0.15
			}
			#Favor
			modifier = {
            	add = 10
            	scope:hui_gui_fei = {
            		has_character_modifier = favored_consort_modifier
            	}
            }
			modifier = {
            	add = 20
            	scope:hui_gui_fei = {
            		has_character_modifier = beloved_consort_modifier
            	}
            }
			modifier = {
            	add = 10
            	scope:hui_gui_fei = {
            		has_character_modifier = favor_boost_modifier
            	}
            }
			#Rank
			modifier = { #The PS is very important
            	add = 15
				primary_spouse ?= scope:hui_gui_fei
            }
			modifier = { #The GC
            	add = 10
            	scope:hui_gui_fei = {
            		has_court_position = grand_consort_court_position
            	}
            }
			modifier = { #SS
            	add = 5
            	scope:hui_gui_fei = {
            		is_married = yes
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
            	}
            }

			#Relation
			modifier = {
            	add = 15
            	OR = {
            		has_relation_lover = scope:hui_gui_fei
					has_relation_soulmate = scope:hui_gui_fei
            	}
            }
			modifier = {
            	add = 10
            	OR = {
            		has_relation_best_friend = scope:hui_gui_fei
					has_relation_friend = scope:hui_gui_fei
            	}
            }
            modifier = {	#Weight down for stress.
				add = 10
				has_trait = lustful
			}
			modifier = {	#Weight up for stress.
				add = -25
				has_trait = chaste
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:hui_gui_fei } }
				factor = 0
			}
        }
    }

	option = { # Just leave me alone
        name = harem_politics.0032.c
        scope:hui_gui_fei = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -5
			}
		}
        stress_impact = {
        	lustful = minor_stress_impact_gain
        }
        ai_chance = {
            base = 50
            ai_value_modifier = {
   				ai_energy = -0.2
				ai_honor = -0.1
				ai_boldness = -0.1
				ai_greed = -0.05
   			}
			opinion_modifier = {
				opinion_target = scope:hui_gui_fei
				min = -15
				max = 15
				multiplier = -0.20
			}
			opinion_modifier = {
				opinion_target = scope:mei_pin
				min = -15
				max = 15
				multiplier = -0.20
			}

            modifier = {	#Weight down for stress.
				add = -25
				has_trait = lustful
			}
			modifier = {	#Weight up for stress.
				add = 25
				has_trait = chaste
			}
        }
    }
	after = {
		add_character_flag = met_mei_pin
		hidden_effect = {
			if = {
				limit = {
					NOT = {
						scope:mei_pin = {
							is_consort_of = root
						}
					}
				}
				scope:mei_pin = {
					death = {
						death_reason = death_vanished
					}
				}
			}
		}
	}
}

#############################################################
##A consort was caught trying to send sensitive information##
#############################################################
harem_politics.0033 = {
	type = character_event
	title = consort_events.0033.t
	desc = {
		desc = harem_politics.0033.start.desc
		first_valid = {
			triggered_desc = { #Is parent of root
				trigger = {
					scope:schemer = {
						is_parent_of = root
					}
				}
				desc = harem_politics.0033.parent.desc
			}
			triggered_desc = { #PS
				trigger = {
					exists = primary_spouse
					scope:schemer = {
						this = root.primary_spouse
					}
				}
				desc = harem_politics.0033.ps.desc
			}
			triggered_desc = { #SS
				trigger = {
					scope:schemer = {
						is_spouse_of = root
					}
				}
				desc = harem_politics.0033.ss.desc
			}
			triggered_desc = {
				desc = harem_politics.0033.concubine.desc
			}
		}
		desc = harem_politics.0033.mid.desc
		first_valid = {
			triggered_desc = { #About me
				trigger = {
					scope:secret_holder = {
						this = root
					}
				}
				desc = harem_politics.0033.root.desc
			}
			triggered_desc = {
				desc = harem_politics.0033.secret_holder.desc
			}
		}
		desc = harem_politics.0033.end.desc
	}
	theme = corruption
	override_background = {
		reference = study
	}
	
	right_portrait = { 	
		character = scope:schemer
		animation = scheme
	}
	left_portrait = { 	
		character = root
		animation = schock
	}
	lower_center_portrait = {
		character = scope:confidant
	}
	
	trigger = {
		is_landed_or_landless_administrative = yes
		this = scope:harem_liege

		exists = scope:schemer
		scope:schemer = {
			is_consort_of = root
		}

		exists = scope:confidant
		scope:confidant = {
			is_vassal_of = root
		}
	}
	
	immediate = {
		if = {
			limit = {
				scope:secret_holder = {
					NOT = {
						this = root
					}
				}
				scope:secret_to_reveal = {
					NOT = {
						is_known_by = root
					}
				}
			}
			scope:secret_to_reveal = {
				reveal_to = root
			}
		}
	}
	
	option = { #Arrest them!
        name = harem_politics.0021.a
		if = {
			limit = {
				scope:secret_holder = {
					this = root
				}
			}
			add_opinion = {
				target = scope:schemer
				modifier = insolent_consort_opinion
				opinion = -50
			}
			add_opinion = {
				target = scope:confidant
				modifier = suspicion_opinion
				opinion = -50
			}
		}
		else = {
			add_opinion = {
				target = scope:schemer
				modifier = insolent_consort_opinion
				opinion = -20
			}
			add_opinion = {
				target = scope:confidant
				modifier = suspicion_opinion
				opinion = -20
			}
		}
		scope:schemer = {
			save_scope_as = recipient
			if = {
				limit = {
					is_consort_of = root
				}
				if = { #If they're a GC, demote them
					limit = {
						has_court_position = grand_consort_court_position
					}
					save_scope_as = employee
					root = {
						save_scope_as = liege
					}
					grand_consort_revoked_court_position_effect = yes
				}
				else = {
					calyver_favor_big_loss_effect = yes
				}

				if = {
					limit = {
						has_character_modifier = favor_boost_modifier
					}
					calyver_stop_favor_boost_event_effect = {
						HAREM_LIEGE = root
						CONSORT = scope:schemer
					}
				}
			}
		}
		imprison = {
			target = scope:schemer
			type = house_arrest
		}
		
		stress_impact = {
			forgiving = minor_stress_impact_gain 
			compassionate = minor_stress_impact_gain 
		}

		save_scope_as = actor
		trigger_event = harem_politics.1000
		
        ai_chance = {
            base = 50
			ai_value_modifier = {
				ai_energy = 0.1
				ai_honor = 0.1
				ai_boldness = 0.1
				ai_vengefulness = -0.1
			}
			
			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -20
				max = 20
				multiplier = -1
			}
			opinion_modifier = { #Opinion of confidant
				opinion_target = scope:confidant
				min = -15
				max = 15
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = -50
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -50
			}
				
			modifier = { #Traits
				has_trait = just
				add = 10
			}
			modifier = { #Traits
				has_trait = vengeful
				add = 15
			}
			
			modifier = { #Favor
			scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = -5
			}
			modifier = { #Favor
			scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = -10
			}
			modifier = { #Favor
			scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}

			#Powerful consorts
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -35
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -10
			}

			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:schemer = { 
					this = root.primary_spouse
				}
				add = -15
			}
			#Grand consort
			modifier = {
				scope:schemer = { 
					has_court_position = grand_consort_court_position
				}
				add = -10
			}
			#Other spouses
			modifier = {
				scope:schemer = { 
					is_spouse_of = root
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = -5
			}
			#Parents
			modifier = {
				scope:schemer = { 
					any_child = {
						this = root
					}
				}
				add = -25
			}

			#Pregnant consort
			modifier = {
				scope:schemer = { 
					has_trait = pregnant
				}
				add = -15
			}

			modifier = { #My secret!
				scope:secret_holder = {
					this = root
				}
				add = 15
			}
			modifier = { #My vassal's secret!
				scope:secret_holder = {
					is_vassal_of = root
				}
				add = 10
			}
        }
    }

	option = { #Execute them
        name = harem_politics.0021.b
		trigger = {
			NOT = { 
				scope:schemer = { has_strong_hook = root } 
			}
		}
		if = {
			limit = {
				scope:secret_holder = {
					this = root
				}
			}
			add_opinion = {
				target = scope:confidant
				modifier = suspicion_opinion
				opinion = -50
			}
		}
		else = {
			add_opinion = {
				target = scope:confidant
				modifier = suspicion_opinion
				opinion = -20
			}
		}
		scope:schemer = {
			death = {
				death_reason = death_punishment
				killer = root
			}
			close_relations_opinion_effect = { VICTIM = scope:schemer EXECUTIONER = root }
		}
		
		stress_impact = {
			forgiving = medium_stress_impact_gain 
			compassionate = medium_stress_impact_gain 

			sadistic = medium_stress_impact_loss
			callous = medium_stress_impact_loss
		}
		
        ai_chance = {
            base = 15
			ai_value_modifier = {
				ai_energy = 0.1
				ai_honor = -0.1
				ai_boldness = 0.1
				ai_vengefulness = 0.25
			}
			
			modifier = { #Alliances
				scope:schemer = {
					any_close_family_member = {
						is_allied_to = root
					}
				}
				add = -20
			}
			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -30
				max = 30
				multiplier = -1
			}
			opinion_modifier = { #Opinion of vassal
				opinion_target = scope:confidant
				min = -30
				max = 30
				multiplier = -1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = -50
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = -50
			}
				
			modifier = { #Traits
				has_trait = just
				add = 10
			}
			modifier = { #Traits
				has_trait = vengeful
				add = 20
			}

			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = -20
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = -25
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 15
			}

			#Powerful consorts
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -100
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -25
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = -25
			}

			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:schemer = { 
					this = root.primary_spouse
				}
				add = -25
			}
			#Grand consort
			modifier = {
				scope:schemer = { 
					has_court_position = grand_consort_court_position
				}
				add = -20
			}
			#Other spouses
			modifier = {
				scope:schemer = { 
					is_spouse_of = root
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = -10
			}
			#Parents
			modifier = {
				scope:schemer = { 
					any_child = {
						this = root
					}
				}
				add = -50
			}

			#Pregnant consort
			modifier = {
				scope:schemer = { 
					has_trait = pregnant
				}
				add = -20
			}

			#Pregnant consort
			modifier = {
				scope:secret_holder = { 
					this = root
				}
				add = 10
			}

			modifier = { #My secret!
				scope:secret_holder = {
					this = root
				}
				add = 20
			}
			modifier = { #My vassal's secret!
				scope:secret_holder = {
					is_vassal_of = root
				}
				add = 15
			}
        }
    }

	option = { #Let them go
        name = consort_events.0001.c
		
		scope:schemer = {
			calyver_favor_medium_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
		}

		stress_impact = {
			just = medium_stress_impact_gain 
			vengeful = medium_stress_impact_gain 
		}
		
        ai_chance = {
            base = 25
			ai_value_modifier = {
				ai_energy = -0.1
				ai_honor = -0.1
				ai_boldness = -0.1
				ai_vengefulness = -0.25
			}
			
			opinion_modifier = { #Opinion of schemer
				opinion_target = scope:schemer
				min = -20
				max = 20
				multiplier = 1
			}
			opinion_modifier = { #Opinion of pregnant consort
				opinion_target = scope:confidant
				min = -15
				max = 15
				multiplier = 1
			}
			
			modifier = { #Stress management
				has_trait = compassionate
				add = 10
			}
			modifier = { #Stress management
				has_trait = forgiving
				add = 10
			}
				
			modifier = { #Traits
				has_trait = just
				add = -25
			}
			modifier = { #Traits
				has_trait = vengeful
				add = -50
			}

			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 5
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = -15
			}
			modifier = { #Favor
				scope:schemer = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = -25
			}

			#Powerful consorts
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_liege_or_above_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 50
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_powerful_vassal_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			modifier = {
				scope:schemer = { 
					any_close_family_member = {
						is_councillor_of = root
						NOT = {
							is_child_of = root
						}
					}
				}
				add = 10
			}
			#Main spouse
			modifier = {
				exists = primary_spouse
				scope:schemer = { 
					this = root.primary_spouse
				}
				add = 15
			}
			#Grand consort
			modifier = {
				scope:schemer = { 
					has_court_position = grand_consort_court_position
				}
				add = 10
			}
			#Other spouses
			modifier = {
				scope:schemer = { 
					is_spouse_of = root
					NOR = {
						this = root.primary_spouse
						has_court_position = grand_consort_court_position
					}
				}
				add = 5
			}
			#Parents
			modifier = {
				scope:schemer = { 
					any_child = {
						this = root
					}
				}
				add = 25
			}
			#Pregnant consort
			modifier = {
				scope:schemer = { 
					has_trait = pregnant
				}
				add = 15
			}
			modifier = { #My secret!
				scope:secret_holder = {
					this = root
				}
				add = -20
			}
			modifier = { #My vassal's secret!
				scope:secret_holder = {
					is_vassal_of = root
				}
				add = -10
			}
        }
    }
	
	after = {
		scope:schemer = {
			if = {
				limit = {
					is_alive = yes
				}
				add_character_flag = {
					flag = flag_caught_leaking_information
					years = 3
				}
			}
		}
	}
}

#########################################
##Someone asks you to release a consort##
#########################################
scripted_trigger harem_politics_valid_relative_0034_trigger = {
	is_physically_able_ai = yes

	OR = {
		is_courtier_of = root
		is_vassal_of = root
	}
	age >= 13

	is_travelling = no

	NOR = {
		has_relation_rival = root
		has_relation_nemesis = root
		is_liege_or_above_of = root
		has_strong_hook = root
	}
}
scripted_trigger harem_politics_valid_consort_0034_trigger = {

	is_courtier_of = root
	is_imprisoned_by = root
	OR = {
		any_relation = {
			type = friend
			harem_politics_valid_relative_0034_trigger = yes
		}
		any_relation = {
			type = best_friend
			harem_politics_valid_relative_0034_trigger = yes
		}
		any_close_family_member = {
			harem_politics_valid_relative_0034_trigger = yes
		}
	}
	NOT = {
		has_character_flag = flag_pleaded_for
	}
}

# harem_politics.0034 = {
# 	type = character_event
# 	title = harem_politics.0001.t
# 	desc = {
# 		desc = harem_politics.0034.start.desc
# 		first_valid = {
# 			triggered_desc = { #Is parent of root
# 				trigger = {
# 					scope:beggar = {
# 						is_parent_of = root
# 					}
# 				}
# 				desc = harem_politics.0034.child.desc
# 			}
# 			triggered_desc = { #Root is their father
# 				trigger = {
# 					scope:beggar = {
# 						is_child_of = root
# 					}
# 				}
# 				desc = harem_politics.0034.parent.desc
# 			}
# 			triggered_desc = {
# 				desc = harem_politics.0034.generic_1.desc
# 			}
# 		}
# 		desc = harem_politics.0034.end.desc
# 	}
# 	theme = family
	
# 	right_portrait = { 	
# 		character = root
# 		animation = eyeroll
# 	}
# 	left_portrait = { 	
# 		character = scope:beggar
# 		animation = beg
# 	}
# 	lower_center_portrait = {
# 		character = scope:consort
# 	}
	
# 	trigger = {
# 		is_physically_able_adult = yes
# 		is_at_war = no
# 		is_landed_or_landless_administrative = yes
# 		is_travelling = no

# 		any_consort = {
# 			harem_politics_valid_consort_0034_trigger = yes
# 		}
# 	}
	
# 	immediate = {
# 		save_scope_as = harem_liege
# 		random_consort = {
# 			limit = {
# 				harem_politics_valid_consort_0034_trigger = yes
# 			}
# 			weight = {
# 				base = 10
# 				#Rank
# 				modifier = {
# 					exists = root.primary_spouse
# 					this = root.primary_spouse
# 					add = 15
# 				}
# 				modifier = {
# 					has_court_position = grand_consort_court_position
# 					add = 10
# 				}
# 				modifier = {
# 					is_married = yes
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 					add = 5
# 				}

# 				modifier = {
# 					NOR = {
# 						has_character_modifier = demoted_primary_spouse_modifier
# 						has_character_modifier = demoted_spouse_modifier
# 					}
# 					add = 50
# 				}

# 				#Good relatives
# 				modifier = {
# 					any_close_family_member = {
# 						is_vassal_of = root
# 					}
# 					add = 10
# 				}
# 				modifier = {
# 					any_close_family_member = {
# 						OR = {
# 							is_powerful_vassal_of = root
# 							is_councillor_of = root
# 							is_liege_or_above_of = root
# 						}
# 					}
# 					add = 20
# 				}
# 				modifier = {
# 					any_child = {
# 						is_child_of = root
# 						is_player_heir_of = root
# 					}
# 					add = 20
# 				}
# 				modifier = {
# 					any_child = {
# 						is_child_of = root
# 						count >= 1
# 					}
# 					add = 10
# 				}
# 				modifier = {
# 					any_child = {
# 						is_child_of = root
# 						count >= 2
# 					}
# 					add = 5
# 				}
# 				modifier = {
# 					any_child = {
# 						is_child_of = root
# 						count >= 3
# 					}
# 					add = 5
# 				}
				
# 				#Favor
# 				modifier = {
# 					has_character_modifier = favor_boost_modifier
# 					add = 15
# 				}
# 				modifier = {
# 					has_character_modifier = favored_consort_modifier
# 					add = 10
# 				}
# 				modifier = {
# 					has_character_modifier = beloved_consort_modifier
# 					add = 20
# 				}
# 			}
# 			save_scope_as = consort
# 		}
# 		scope:consort = {
# 			if = { #Friends
# 				limit = {
# 					any_relation = {
# 						type = friend
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 				}
# 				every_relation = {
# 					type = friend
# 					limit = {
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 					add_to_list = pleaders_list
# 				}
# 			}
# 			if = { #Best friends
# 				limit = {
# 					any_relation = {
# 						type = best_friend
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 				}
# 				every_relation = {
# 					type = best_friend
# 					limit = {
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 					add_to_list = pleaders_list
# 				}
# 			}
# 			if = { #Relatives
# 				limit = {
# 					any_close_family_member = {
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 				}
# 				every_close_family_member = {
# 					limit = {
# 						harem_politics_valid_relative_0034_trigger = yes
# 					}
# 					add_to_list = pleaders_list
# 				}
# 			}
# 		}
# 		random_in_list = {
# 			list = pleaders_list
# 			weight = { 
# 				base = 30
				
# 				modifier = { 
# 					is_child_of = root
# 					add = 5
# 				}
# 				modifier = { 
# 					is_player_heir_of = root
# 					add = 5
# 				}

# 				modifier = {
# 					is_close_family_of = root
# 					add = 10
# 				}

# 				modifier = {
# 					is_vassal_of = root
# 					add = 5
# 				}
# 				modifier = {
# 					is_powerful_vassal_of = root
# 					add = 10
# 				}
# 				modifier = {
# 					is_councillor_of = root
# 					add = 5
# 				}
# 			}
# 			save_scope_as = beggar
# 		}
# 	}
	
# 	option = { #Let them go
#         name = harem_politics.0034.a
# 		trigger = {
# 			scope:consort = { is_imprisoned_by = root } 
# 		}
# 		hidden_effect = {
# 			# Notification to the imprisoner
# 			send_interface_toast = {
# 				title = recipient_released_from_prison
# 				left_icon = scope:consort
# 				scope:consort = {
# 					add_opinion = {
# 						modifier = released_from_prison
# 						target = root
# 						opinion = 5
# 					}
# 				}
# 			}
# 		}

# 		scope:consort = {			
# 			if = {
# 				limit = { is_imprisoned = yes }
# 				release_from_prison = yes
# 			}
# 			hidden_effect = {
# 				add_opinion = {
# 					target = scope:beggar
# 					modifier = plead_for_me_opinion
# 				}
# 			}
# 		}

# 		if = {
# 			limit = {
# 				has_imprisonment_reason = scope:consort
# 			}
# 			stress_impact = {
# 				just = medium_stress_impact_gain
# 			}
# 		}
# 		stress_impact = {
# 			sadistic = minor_stress_gain
# 			callous = minor_stress_gain
# 			stubborn = minor_stress_gain
# 			wrathful = minor_stress_gain
# 		}
		
#         ai_chance = {
#             base = 50
# 			ai_value_modifier = {
# 				ai_vengefulness = -0.2
# 				ai_compassion = 0.2
# 			}
			
# 			opinion_modifier = { #Opinion of schemer
# 				opinion_target = scope:consort
# 				min = -20
# 				max = 20
# 				multiplier = 0.5
# 			}
# 			opinion_modifier = { #Opinion of beggar
# 				opinion_target = scope:beggar
# 				min = -15
# 				max = 15
# 				multiplier = 0.5
# 			}
			
# 			modifier = { #Traits
# 				has_trait = compassionate
# 				add = 15
# 			}
# 			modifier = { #Traits
# 				has_trait = forgiving
# 				add = 15
# 			}
# 			modifier = { #Traits
# 				has_trait = fickle
# 				add = 15
# 			}
				
# 			modifier = { #Stress management
# 				has_trait = sadistic
# 				add = -25
# 			}
# 			modifier = { #Stress management
# 				has_trait = callous
# 				add = -25
# 			}
# 			modifier = { #Stress management
# 				has_trait = wrathful
# 				add = -25
# 			}
# 			modifier = { #Traits
# 				has_trait = stubborn
# 				add = -25
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				NOT = {	
# 					has_imprisonment_reason = scope:consort
# 				}
# 				add = 15
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				has_imprisonment_reason = scope:consort
# 				add = -25
# 			}
			
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = 10
# 			}
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = 15
# 			}
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = 20
# 			}

# 			modifier = { #Favor
# 				scope:consort = { 
# 					has_character_modifier = unfavored_consort_modifier
# 				}
# 				add = -5
# 			}
# 			modifier = { #Favor
# 				scope:consort = { 
# 					has_character_modifier = forgotten_consort_modifier
# 				}
# 				add = -10
# 			}

# 			#Powerful consorts
# 			modifier = {
# 				scope:consort = { 
# 					any_close_family_member = {
# 						is_powerful_vassal_of = root
# 						NOT = {
# 							is_child_of = root
# 						}
# 					}
# 				}
# 				add = 15
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_close_family_member = {
# 						is_councillor_of = root
# 						NOT = {
# 							is_child_of = root
# 						}
# 					}
# 				}
# 				add = 10
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_close_family_member = {
# 						is_liege_or_above_of = root
# 						NOT = {
# 							is_child_of = root
# 						}
# 					}
# 				}
# 				add = 75
# 			}

# 			#Powerful children
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_player_heir_of = root
# 					}
# 				}
# 				add = 10
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 1
# 					}
# 				}
# 				add = 10
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 2
# 					}
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 3
# 					}
# 				}
# 				add = 5
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = 15
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = 10
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = 5
# 			}

# 			#Parents
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						this = root
# 					}
# 				}
# 				add = 25
# 			}

# 			#Pregnant consort
# 			modifier = {
# 				scope:consort = { 
# 					has_trait = pregnant
# 				}
# 				add = 10
# 			}

# 			#Evil consorts
# 			modifier = {
# 				scope:consort = { 
# 					harem_politics_evil_consort_trigger = no
# 				}
# 				add = 10
# 			}
# 			#Virtuous consorts
# 			modifier = {
# 				scope:consort = { 
# 					num_virtuous_traits >= 1
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					num_virtuous_traits >= 2
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					num_virtuous_traits >= 3
# 				}
# 				add = 5
# 			}

# 			#Beggar
# 			modifier = {
# 				scope:beggar = { 
# 					is_councillor_of = root
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_powerful_vassal_of = root
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_vassal_of = root
# 				}
# 				add = 5
# 			}

# 			modifier = {
# 				scope:beggar = { 
# 					is_child_of = root
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_player_heir_of = root
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_parent_of = root
# 				}
# 				add = 20
# 			}
#         }
#     }

# 	option = { #Arrest them
#         name = harem_politics.0034.b
# 		trait = sadistic
# 		trait = callous
# 		trigger = {
# 			scope:beggar = { is_courtier_of = root } 
# 			OR = {
# 				has_trait = sadistic
# 				has_trait = callous
# 				has_trait = wrathful
# 			}
# 		}

# 		save_scope_as = actor

# 		imprison = {
# 			target = scope:beggar
# 			type = house_arrest
# 		}
# 		scope:beggar = {
# 			save_scope_as = recipient
# 		}
		
# 		if = {
# 			limit = {
# 				NOT = {	
# 					has_imprisonment_reason = scope:beggar
# 				}
# 			}
# 			stress_impact = {
# 				just = medium_stress_impact_gain
# 			}
# 		}
# 		stress_impact = {
# 			forgiving = medium_stress_impact_gain 
# 			compassionate = medium_stress_impact_gain 
# 		}
		
# 		trigger_event = harem_politics.1000
		
#         ai_chance = {
# 			base = 50
# 			ai_value_modifier = {
# 				ai_honor = -0.1
# 				ai_vengefulness = 0.15
# 				ai_compassion = -0.2
# 			}

# 			opinion_modifier = { #Opinion of schemer
# 				opinion_target = scope:consort
# 				min = -15
# 				max = 15
# 				multiplier = -0.5
# 			}
# 			opinion_modifier = { #Opinion of beggar
# 				opinion_target = scope:beggar
# 				min = -20
# 				max = 20
# 				multiplier = -0.5
# 			}
			
# 			modifier = { #Stress management
# 				add = -30
# 				has_trait = forgiving
# 			}
# 			modifier = { #Stress management
# 				add = -30
# 				has_trait = compassionate
# 			}

# 			modifier = { #Traits
# 				add = 40
# 				has_trait = sadistic
# 			}
# 			modifier = { #Traits
# 				add = 40
# 				has_trait = callous
# 			}
# 			modifier = { #Traits
# 				add = 40
# 				has_trait = wrathful
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				NOT = {	
# 					has_imprisonment_reason = scope:beggar
# 				}
# 				add = -25
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				has_imprisonment_reason = scope:beggar
# 				add = 20
# 			}
			
# 			modifier = { #Kids
# 				scope:beggar = {
# 					is_child_of = root
# 				}
# 				add = -20
# 			}
# 			modifier = { #Kids
# 				scope:beggar = {
# 					is_player_heir_of = root
# 				}
# 				add = -20
# 			}

# 			modifier = { #Parents
# 				scope:beggar = { 
# 					is_parent_of = root
# 				}
# 				add = -30
# 			}
# 		}
#     }

# 	option = { #Ignore them
#         name = harem_politics.0034.c
		
# 		scope:beggar = {
# 			add_opinion = {
# 				target = root
# 				modifier = rejected_plea_opinion
# 			}
# 		}

# 		if = {
# 			limit = {
# 				NOT = {	
# 					has_imprisonment_reason = scope:consort
# 				}
# 			}
# 			stress_impact = {
# 				just = medium_stress_impact_gain
# 			}
# 		}

# 		stress_impact = {
# 			forgiving = medium_stress_impact_gain 
# 			compassionate = medium_stress_impact_gain 
# 			fickle = minor_stress_gain
# 		}
		
#         ai_chance = {
#             base = 50
# 			ai_value_modifier = {
# 				ai_vengefulness = 0.1
# 				ai_compassion = -0.2
# 			}
			
# 			opinion_modifier = { #Opinion of schemer
# 				opinion_target = scope:consort
# 				min = -20
# 				max = 20
# 				multiplier = -0.5
# 			}
# 			opinion_modifier = { #Opinion of beggar
# 				opinion_target = scope:beggar
# 				min = -15
# 				max = 15
# 				multiplier = -0.5
# 			}
			
# 			modifier = { #Stress management
# 				has_trait = compassionate
# 				add = -25
# 			}
# 			modifier = { #Stress management
# 				has_trait = forgiving
# 				add = -25
# 			}
# 			modifier = { #Stress management
# 				has_trait = fickle
# 				add = -15
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				NOT = {	
# 					has_imprisonment_reason = scope:consort
# 				}
# 				add = -25
# 			}
# 			modifier = { #Just characters
# 				has_trait = just
# 				has_imprisonment_reason = scope:consort
# 				add = 15
# 			}
				
# 			modifier = { #Traits
# 				has_trait = stubborn
# 				add = 15
# 			}
			
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = -10
# 			}
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = -15
# 			}
# 			modifier = { #Favor
# 			scope:consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = -20
# 			}

# 			modifier = { #Favor
# 				scope:consort = { 
# 					has_character_modifier = unfavored_consort_modifier
# 				}
# 				add = 5
# 			}
# 			modifier = { #Favor
# 				scope:consort = { 
# 					has_character_modifier = forgotten_consort_modifier
# 				}
# 				add = 15
# 			}

# 			#Powerful consorts
# 			modifier = {
# 				scope:consort = { 
# 					any_close_family_member = {
# 						is_powerful_vassal_of = root
# 						NOT = {
# 							is_child_of = root
# 						}
# 					}
# 				}
# 				add = -15
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_close_family_member = {
# 						is_councillor_of = root
# 						NOT = {
# 							is_child_of = root
# 						}
# 					}
# 				}
# 				add = -10
# 			}

# 			#Powerful children
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_player_heir_of = root
# 					}
# 				}
# 				add = -15
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 1
# 					}
# 				}
# 				add = -10
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 2
# 					}
# 				}
# 				add = -5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						is_child_of = root
# 						count >= 3
# 					}
# 				}
# 				add = -5
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = -15
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = -10
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = -5
# 			}

# 			#Parents
# 			modifier = {
# 				scope:consort = { 
# 					any_child = {
# 						this = root
# 					}
# 				}
# 				add = -25
# 			}

# 			#Pregnant consort
# 			modifier = {
# 				scope:consort = { 
# 					has_trait = pregnant
# 				}
# 				add = -15
# 			}

# 			#Evil consorts
# 			modifier = {
# 				scope:consort = { 
# 					harem_politics_evil_consort_trigger = yes
# 				}
# 				add = 15
# 			}
# 			#Sinful consorts
# 			modifier = {
# 				scope:consort = { 
# 					num_sinful_traits >= 1
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					num_sinful_traits >= 2
# 				}
# 				add = 5
# 			}
# 			modifier = {
# 				scope:consort = { 
# 					num_sinful_traits >= 3
# 				}
# 				add = 5
# 			}

# 			#Beggar
# 			modifier = {
# 				scope:beggar = { 
# 					is_councillor_of = root
# 				}
# 				add = -5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_powerful_vassal_of = root
# 				}
# 				add = -5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_vassal_of = root
# 				}
# 				add = -5
# 			}

# 			modifier = {
# 				scope:beggar = { 
# 					is_child_of = root
# 				}
# 				add = -5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_player_heir_of = root
# 				}
# 				add = -5
# 			}
# 			modifier = {
# 				scope:beggar = { 
# 					is_parent_of = root
# 				}
# 				add = -25
# 			}
#         }
#     }
	
# 	after = {
# 		scope:consort = {
# 			add_character_flag = {
# 				flag = flag_pleaded_for
# 				years = 5
# 			}
# 		}
# 	}
# }

#################################
##A consort is stirring the pot##
#################################
scripted_trigger harem_politics_valid_consort_0035_trigger = {
	is_physically_able_ai_adult = yes
	is_courtier_of = root

	harem_politics_punished_consort_trigger = no
	is_demoted_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no

	hp_accepts_harems = yes

	is_healthy = yes
	has_contagious_disease_trigger = no

	
	NOR = {
		has_trait = lunatic_1
		has_trait = lunatic_genetic
		has_trait = possessed_1
		has_trait = possessed_genetic

		has_relation_rival = root
		has_relation_nemesis = root

		has_opinion_modifier = {
			modifier = forced_me_concubine_marriage_opinion
			target = root
		}
	}

	OR = {
		AND = {
			is_travelling = yes
			current_travel_plan = {
				travel_plan_owner = root
			}
		}
		AND = {
			is_travelling = no
			root = {
				is_travelling = no
			}
		}
	}
}

scripted_trigger harem_politics_troublesome_consort_trigger = {
	harem_politics_valid_consort_0035_trigger = yes

	harem_politics_evil_consort_trigger = yes

	opinion = {
		target = root
		value >= 5
	}
	opinion = {
		target = $TARGET_CONSORT$
		value <= 10
	}

	stress <= normal_baseline_stress

	NOR = {
		this = $TARGET_CONSORT$

		has_relation_friend = $TARGET_CONSORT$
		has_relation_best_friend = $TARGET_CONSORT$

		has_relation_lover = $TARGET_CONSORT$
		has_relation_soulmate = $TARGET_CONSORT$
	}
}

# harem_politics.0035 = {
# 	type = character_event
# 	title = harem_politics.0035.t
# 	desc = harem_politics.0035.start.desc
# 	theme = unfriendly
# 	orphan = yes
# 	override_background = {
# 		reference = study
# 	}
	
# 	right_portrait = { 	
# 		character = scope:troublesome_consort
# 		animation = flirtation
# 	}
# 	left_portrait = { 	
# 		character = root
# 		animation = personality_rational
# 	}
# 	lower_center_portrait = {
# 		character = scope:target_consort
# 	}
	
# 	trigger = {
# 		highest_held_title_tier >= tier_county
# 		is_physically_able_adult = yes
# 		is_at_war = no
# 		is_landed_or_landless_administrative = yes

# 		any_consort = {
# 			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
# 			is_imprisoned = no
# 			count >= 3
# 		}
# 		any_consort = {
# 			harem_politics_valid_consort_0035_trigger = yes
# 			save_temporary_scope_as = check_target_consort
# 		}
# 		any_consort = {
# 			harem_politics_troublesome_consort_trigger = { TARGET_CONSORT = scope:check_target_consort }
# 		}

# 		NOR = {
# 			has_trait = celibate
# 			has_sexuality = asexual

# 			has_character_flag = flag_had_troublesome_consort
# 		}
# 	}

# 	weight_multiplier = {
# 		base = 1
# 		modifier = {
# 			add = 0.1
# 			highest_held_title_tier >= tier_kingdom
# 		}
# 		modifier = {
# 			add = 0.2
# 			any_consort = {
# 				is_courtier_of = root
# 				count >= 6
# 			}
# 		}
# 		modifier = {
# 			add = 0.2
# 			any_child = {
# 				is_alive = yes
# 				count <= 3
# 			}
# 		}
# 	}
	
# 	immediate = {
# 		save_scope_as = harem_liege

# 		random_consort = {
# 			limit = {
# 				harem_politics_valid_consort_0035_trigger = yes
# 			}
# 			weight = {
# 				base = 10
# 				#Rank
# 				modifier = {
# 					exists = root.primary_spouse
# 					this = root.primary_spouse
# 					add = 15
# 				}
# 				modifier = {
# 					has_court_position = grand_consort_court_position
# 					add = 10
# 				}
# 				modifier = {
# 					is_married = yes
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 					add = 5
# 				}

# 				#Good relatives
# 				modifier = {
# 					any_close_family_member = {
# 						is_vassal_of = root
# 					}
# 					add = 5
# 				}
# 				modifier = {
# 					any_close_family_member = {
# 						OR = {
# 							is_powerful_vassal_of = root
# 							is_councillor_of = root
# 							is_liege_or_above_of = root
# 						}
# 					}
# 					add = 5
# 				}

# 				#Favor
# 				modifier = {
# 					has_character_modifier = favored_consort_modifier
# 					add = 10
# 				}
# 				modifier = {
# 					has_character_modifier = favor_boost_modifier
# 					add = 15
# 				}
# 				modifier = {
# 					has_character_modifier = beloved_consort_modifier
# 					add = 20
# 				}
# 			}
# 			save_scope_as = target_consort
# 		}
# 		random_consort = {
# 			limit = {
# 				harem_politics_troublesome_consort_trigger = { TARGET_CONSORT = scope:target_consort }
# 			}
# 			weight = {
# 				base = 10
# 				#Rank
# 				modifier = {
# 					exists = root.primary_spouse
# 					this = root.primary_spouse
# 					add = -10
# 				}
# 				modifier = {
# 					has_court_position = grand_consort_court_position
# 					add = -5
# 				}
# 				modifier = {
# 					is_married = yes
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 					add = -5
# 				}

# 				#Good relatives
# 				modifier = {
# 					any_close_family_member = {
# 						is_vassal_of = root
# 					}
# 					add = 5
# 				}
# 				modifier = {
# 					any_close_family_member = {
# 						OR = {
# 							is_powerful_vassal_of = root
# 							is_councillor_of = root
# 							is_liege_or_above_of = root
# 						}
# 					}
# 					add = 5
# 				}
				
# 				#Traits
# 				modifier = {
# 					has_trait = ambitious
# 					add = 5
# 				}
# 				modifier = {
# 					has_trait = greedy
# 					add = 5
# 				}
# 				modifier = {
# 					has_trait = arrogant
# 					add = 5
# 				}

# 				#Relation
# 				modifier = {
# 					has_relation_potential_rival = scope:target_consort
# 					add = 10
# 				}
# 				modifier = {
# 					has_relation_rival = scope:target_consort
# 					add = 15
# 				}
# 				modifier = {
# 					has_relation_nemesis = scope:target_consort
# 					add = 20
# 				}

# 				opinion_modifier = { #Opinion of target_consort
# 					opinion_target = scope:target_consort
# 					min = -20
# 					max = 20
# 					multiplier = -1
# 				}
# 			}
# 			save_scope_as = troublesome_consort
# 		}

# 		had_sex_with_effect = {
# 			CHARACTER = scope:troublesome_consort
# 			PREGNANCY_CHANCE = pregnancy_chance
# 		}
# 	}
	
# 	option = { #Agree with them
#         name = harem_politics.0035.a

# 		set_relation_potential_rival = scope:target_consort
# 		add_opinion = {
# 			target = scope:target_consort
# 			modifier = respect_opinion
# 			opinion = -10
# 		}

# 		scope:troublesome_consort = {
# 			calyver_favor_minor_gain_effect = yes
# 			add_opinion = {
# 				modifier = pleased_opinion
# 				target = root
# 				opinion = 10
# 			}		
# 		}
# 		scope:target_consort = {
# 			calyver_favor_minor_loss_effect = yes
# 		}

# 		stress_impact = {
# 			just = minor_stress_gain
# 			forgiving = miniscule_stress_impact_gain
# 			compassionate = miniscule_stress_impact_gain
# 		}
		
#         ai_chance = {
#             base = 50
# 			ai_value_modifier = {
# 				ai_honor = -0.2
# 				ai_compassion = -0.1
# 				ai_energy = -0.2
# 			}
			
# 			opinion_modifier = { #Opinion of target_consort
# 				opinion_target = scope:target_consort
# 				min = -20
# 				max = 20
# 				multiplier = -1
# 			}
# 			opinion_modifier = { #Opinion of troublesome_consort
# 				opinion_target = scope:troublesome_consort
# 				min = -15
# 				max = 15
# 				multiplier = 1
# 			}
			
# 			modifier = { #Traits
# 				has_trait = compassionate
# 				add = -15
# 			}
# 			modifier = { #Traits
# 				has_trait = forgiving
# 				add = -15
# 			}
				
# 			modifier = { #Stress management
# 				has_trait = just
# 				add = -25
# 			}
			
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = 10
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = 15
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = 20
# 			}

# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = -10
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = -15
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = -20
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:troublesome_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = 15
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = 10
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = 5
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:target_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = -20
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:target_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = -15
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:target_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = -10
# 			}

# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_concubine = yes
# 				}
# 				scope:target_consort = { 
# 					is_spouse_of = root
# 				}
# 				add = -10
# 			}

# 			#Relation
# 			modifier = {
# 				has_relation_potential_lover = scope:troublesome_consort
# 				add = 5
# 			}
# 			modifier = {
# 				has_relation_lover = scope:troublesome_consort
# 				add = 10
# 			}
# 			modifier = {
# 				has_relation_soulmate = scope:troublesome_consort
# 				add = 20
# 			}
#         }
#     }

# 	option = { #Disagree with them
#         name = harem_politics.0035.b

# 		add_opinion = {
# 			target = scope:troublesome_consort
# 			modifier = respect_opinion
# 			opinion = -10
# 		}

# 		scope:troublesome_consort = {
# 			calyver_favor_minor_loss_effect = yes
# 			add_opinion = {
# 				modifier = disappointed_opinion
# 				target = root
# 				opinion = -15
# 			}		
# 		}
# 		scope:target_consort = {
# 			calyver_favor_minor_gain_effect = yes
# 		}

# 		stress_impact = {
# 			forgiving = minor_stress_gain
# 			compassionate = minor_stress_gain
# 		}
		
#         ai_chance = {
#             base = 50
# 			ai_value_modifier = {
# 				ai_honor = 0.2
# 				ai_compassion = -0.2
# 				ai_energy = 0.1
# 			}
			
# 			opinion_modifier = { #Opinion of target_consort
# 				opinion_target = scope:target_consort
# 				min = -20
# 				max = 20
# 				multiplier = 1
# 			}
# 			opinion_modifier = { #Opinion of troublesome_consort
# 				opinion_target = scope:troublesome_consort
# 				min = -15
# 				max = 15
# 				multiplier = -1
# 			}
			
# 			modifier = { #Traits
# 				has_trait = compassionate
# 				add = -25
# 			}
# 			modifier = { #Traits
# 				has_trait = forgiving
# 				add = -25
# 			}
				
# 			modifier = { #Stress management
# 				has_trait = just
# 				add = 10
# 			}
			
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = -10
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = -15
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = -20
# 			}

# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = 10
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = 15
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = 20
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:troublesome_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = -25
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = -15
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = -10
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:target_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = 20
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:target_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = 15
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:target_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = 10
# 			}

# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_spouse_of = root
# 				}
# 				scope:target_consort = { 
# 					is_concubine = yes
# 				}
# 				add = 5
# 			}

# 			#Relation
# 			modifier = {
# 				has_relation_potential_lover = scope:target_consort
# 				add = 5
# 			}
# 			modifier = {
# 				has_relation_lover = scope:target_consort
# 				add = 10
# 			}
# 			modifier = {
# 				has_relation_soulmate = scope:target_consort
# 				add = 20
# 			}
#         }
#     }

# 	option = { #Ignore them
#         name = harem_politics.0035.c

# 		add_opinion = {
# 			target = scope:troublesome_consort
# 			modifier = respect_opinion
# 			opinion = -5
# 		}

# 		scope:troublesome_consort = {
# 			add_opinion = {
# 				modifier = disappointed_opinion
# 				target = root
# 				opinion = -5
# 			}		
# 		}
		
#         ai_chance = {
#             base = 65
# 			ai_value_modifier = {
# 				ai_honor = -0.1
# 				ai_compassion = 0.1
# 				ai_energy = -0.2
# 			}
			
# 			opinion_modifier = { #Opinion of target_consort
# 				opinion_target = scope:target_consort
# 				min = -40
# 				max = 40
# 				multiplier = 1
# 			}
# 			opinion_modifier = { #Opinion of troublesome_consort
# 				opinion_target = scope:troublesome_consort
# 				min = -40
# 				max = 40
# 				multiplier = -1
# 			}
			
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = -5
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = -10
# 			}
# 			modifier = { #Favor
# 				scope:troublesome_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = -15
# 			}

# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favored_consort_modifier
# 				}
# 				add = -5
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = favor_boost_modifier
# 				}
# 				add = -10
# 			}
# 			modifier = { #Favor
# 				scope:target_consort = { 
# 					has_character_modifier = beloved_consort_modifier
# 				}
# 				add = -15
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:troublesome_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = -15
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = -10
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = -5
# 			}

# 			#Main spouse
# 			modifier = {
# 				exists = primary_spouse
# 				scope:target_consort = { 
# 					this = root.primary_spouse
# 				}
# 				add = -15
# 			}
# 			#Grand consort
# 			modifier = {
# 				scope:target_consort = { 
# 					has_court_position = grand_consort_court_position
# 				}
# 				add = -10
# 			}
# 			#Other spouses
# 			modifier = {
# 				scope:target_consort = { 
# 					is_spouse_of = root
# 					NOR = {
# 						this = root.primary_spouse
# 						has_court_position = grand_consort_court_position
# 					}
# 				}
# 				add = -5
# 			}

# 			modifier = {
# 				scope:troublesome_consort = { 
# 					is_concubine = yes
# 				}
# 				scope:target_consort = { 
# 					is_concubine = yes
# 				}
# 				add = 5
# 			}

# 			#Relation
# 			modifier = {
# 				has_relation_potential_lover = scope:troublesome_consort
# 				add = -5
# 			}
# 			modifier = {
# 				has_relation_lover = scope:troublesome_consort
# 				add = -10
# 			}
# 			modifier = {
# 				has_relation_soulmate = scope:troublesome_consort
# 				add = -15
# 			}

# 			#Relation
# 			modifier = {
# 				has_relation_potential_lover = scope:target_consort
# 				add = -5
# 			}
# 			modifier = {
# 				has_relation_lover = scope:target_consort
# 				add = -10
# 			}
# 			modifier = {
# 				has_relation_soulmate = scope:target_consort
# 				add = -15
# 			}
#         }
#     }
	
# 	after = {
# 		add_character_flag = {
# 			flag = flag_had_troublesome_consort
# 			years = 4
# 		}
# 	}
# }

############################################
##The Empress Dowager lectures the Empress##
############################################
scripted_trigger harem_politics_langhua_trigger = {
	is_courtier_of = root
	is_physically_able_ai = yes

	is_demoted_consort_trigger = no
	harem_politics_punished_consort_trigger = no

	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }

	NOR = { 
		has_opinion_modifier = {
			target = root
			modifier = forced_me_concubine_marriage_opinion
		}
		
		has_trait = ill
		has_trait = wounded

		has_trait = pregnant

		has_relation_rival = root
		has_relation_nemesis = root
	}
	trigger_if = { #If there's an available PS, they are the GC
		limit = {
			root.primary_spouse ?= {
				is_courtier_of = root
			}
		}
		this = root.primary_spouse
	}
	trigger_else = { #Else, they're the GC
		has_court_position = grand_consort_court_position
	}
	trigger_if = {
		limit = {
			is_travelling = yes	
		}
		current_travel_plan = {
			travel_plan_owner = root
		}
	}
	trigger_else = {
		is_travelling = no
		root = {
			is_travelling = no
		}
	}
}

scripted_trigger harem_politics_zhenhuan_trigger = {
	is_physically_able_ai = yes

	harem_politics_punished_consort_trigger = no

	trigger_if = {
		limit = {
			root.religion = religion:islam_religion
		}
		is_head_of_the_harem_trigger = {
			LIEGE = root
		}
	}
	trigger_else = {
		is_parent_of = root
	}

	NOR = { 
		this = $LANGHUA$
		is_consort_of = root

		has_trait = ill
		has_trait = wounded

		has_trait = pregnant

		has_relation_rival = root
		has_relation_nemesis = root

		has_relation_best_friend = $LANGHUA$
		has_relation_friend = $LANGHUA$
		has_relation_lover = $LANGHUA$
		has_relation_soulmate = $LANGHUA$

		has_trait = forgiving
		has_trait = compassionate
		has_trait = humble
		has_trait = content

		has_trait = lazy
		has_trait = shy
		has_trait = craven
	}
	trait_compatibility = {
		target = $LANGHUA$
		value <= low_negative_trait_compatibility
	}
	trigger_if = {
		limit = {
			is_travelling = yes	
		}
		current_travel_plan = {
			travel_plan_owner = root
		}
	}
	trigger_else = {
		is_travelling = no
		root = {
			is_travelling = no
		}
	}
}

harem_politics.0036 = {
	type = character_event
	title = harem_politics.0036.t
	desc = {
		desc = harem_politics.0036.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = local_var:children
				}
				desc = harem_politics.0036.children.desc
			}
			triggered_desc = {
				trigger = {
					exists = local_var:rivals
				}
				desc = harem_politics.0036.rivals.desc
			}
			desc = harem_politics.0036.unfavored.desc
		}
		desc = harem_politics.0036.end.desc
	}
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait = {
		character = scope:langhua
		animation = shame
	}
	right_portrait  = {
		character = scope:zhen_huan
		animation = disapproval
	}
	
	trigger = {
		hp_accepts_harems = yes
		OR = {
			# Scenario 1: Root is 24+ with only 3 eligible heirs
			AND = {
				age >= 24
				any_child = {
					is_alive = yes
					character_gender_can_inherit_from_trigger = { CHARACTER = root }
					has_any_bastard_trait_trigger = no
					count <= 3
				}
				NOR = {
					has_trait = eunuch
					has_trait = celibate
					has_trait = devoted
					has_trait = pregnant
				}
			}
			# Scenario 2: 4 consorts who are rivals or nemesis
			AND = {
				any_consort = {
					is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
					OR = {
						any_relation = {
							type = rival
							is_consort_of = root
							is_courtier_of = root
						}
						any_relation = {
							type = nemesis
							is_consort_of = root
							is_courtier_of = root
						}
					}
					count >= 4
				}
			}
			# Scenario 3: 4 consorts who are unfavored or forgotten
			AND = {
				any_consort = {
					harem_politics_unfavored_consort_trigger = yes
					count >= 4
				}
			}
		}
		# Standard triggers
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			is_imprisoned = no
			count >= 4
		}
		any_consort = {
			harem_politics_langhua_trigger = yes
			save_temporary_scope_as = temporary_langhua
		}
		any_courtier = {
			harem_politics_zhenhuan_trigger = { LANGHUA = scope:temporary_langhua }
		}
		NOR = {
			has_character_flag = had_zhenhuan_event_flag
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.2
			religion = religion:islam_religion
		}
		modifier = {
			add = 0.1
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			add = 0.1
			any_child = {
				is_alive = yes
				character_gender_can_inherit_from_trigger = { CHARACTER = root }
				count = 0
			}
		}
		modifier = {
			add = 0.1
			any_consort = {
				is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
				OR = {
					any_relation = {
						type = rival
						is_consort_of = root
						is_courtier_of = root
					}
					any_relation = {
						type = nemesis
						is_consort_of = root
						is_courtier_of = root
					}
				}
				count >= 6
			}
		}
		modifier = {
			add = 0.1
			any_consort = {
				harem_politics_unfavored_consort_trigger = yes
				count >= 8
			}
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 3
				has_character_flag = gc_promoting_harmony
			}
			add = 0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege

		# Find the reason
		if = {
			limit = {
				age >= 24
				any_child = {
					is_alive = yes
					character_gender_can_inherit_from_trigger = { CHARACTER = root }
					has_any_bastard_trait_trigger = no
					count <= 3
				}
				NOR = {
					has_trait = eunuch
					has_trait = celibate
					has_trait = devoted
					has_trait = pregnant
				}
			}
			set_local_variable = {
				name = children
				value = yes
			}
		}
		else_if = {
			limit = {
				any_consort = {
					is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
					OR = {
						any_relation = {
							type = rival
							is_consort_of = root
							is_courtier_of = root
						}
						any_relation = {
							type = nemesis
							is_consort_of = root
							is_courtier_of = root
						}
					}
					count >= 4
				}
			}
			set_local_variable = {
				name = rivals
				value = yes
			}
		}
		else = {
			set_local_variable = {
				name = unfavored
				value = yes
			}
		}

		random_consort = { #Find Langhua
			limit = {
				harem_politics_langhua_trigger = yes
			}
			save_scope_as = langhua
		}

		random_courtier = {
			limit = {
				harem_politics_zhenhuan_trigger = { LANGHUA = scope:langhua }
			}
			weight = {
				base = 20
				modifier = {
					add = age
				}
				modifier = {
					sex_same_as = scope:langhua
					add = 20
				}
				compatibility_modifier = { #Trait compatibility
					compatibility_target = scope:langhua
					min = -15
					max = 15
					multiplier = -1
				}
				modifier = {
					sex_opposite_of = root
					add = 20
				}
			}
			save_scope_as = zhen_huan
		}
		
		hidden_effect = {
			scope:zhen_huan = {
				add_opinion = {
					target = scope:langhua
					modifier = frustrated_opinion
					opinion = -10
				}
			}
			scope:langhua = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = frustrated_opinion
					opinion = -10
				}
			}
		}
	}
	
	option = { #Side with the Empress
        name = harem_politics.0036.a
		scope:langhua = {
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
				opinion = 15
			}
			#They gain a bit of favor
			calyver_favor_moderate_gain_effect = yes
		}
		scope:zhen_huan = {
			add_opinion = {
				target = root
				modifier = frustrated_opinion
				opinion = -10
			}
			hidden_effect = {
				if = {
					limit = {
						has_trait = vengeful
					}
					if = {
						limit = {
							NOR = { 
								has_relation_grudge = scope:langhua
								has_relation_rival = scope:langhua
								has_relation_nemesis = scope:langhua
							}
						}
						set_relation_grudge = {
							REASON = consort_rival_reason
							target = scope:langhua
						}
					}
				}
			}
		}
		add_opinion = {
			target = scope:zhen_huan
			modifier = disapproving_opinion
		}

		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
            base = 50
        	ai_value_modifier = {
				ai_compassion = -0.4
				ai_boldness = 0.3
				ai_sociability = 0.2				
				ai_honor = 0.2
   			}
			opinion_modifier = {
				opinion_target = scope:langhua
				multiplier = 0.2
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:langhua
				multiplier = 0.15
			}

            modifier = { #Favor
				scope:langhua = { 
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor boost
				scope:langhua = { 
					has_character_modifier = favor_boost_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:langhua = { 
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}

			modifier = { #Traits
				has_trait = forgiving
				add = -25
			}
			modifier = { #Traits
				has_trait = compassionate
				add = -25
			}
			modifier = { #Traits
				has_trait = craven
				add = -25
			}
			modifier = { #Traits
				has_trait = shy
				add = -25
			}
        }
    }
	
	option = { #Side with the Empress Dowager
        name = harem_politics.0036.b
		scope:zhen_huan = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 10
			}
		}
		scope:langhua = {
			add_opinion = {
				target = root
				modifier = frustrated_opinion
				opinion = -15
			}
			hidden_effect = {
				if = {
					limit = {
						has_trait = vengeful
					}
					if = {
						limit = {
							NOR = { 
								has_relation_grudge = scope:zhen_huan
								has_relation_rival = scope:zhen_huan
								has_relation_nemesis = scope:zhen_huan
							}
						}
						set_relation_grudge = {
							REASON = consort_rival_reason
							target = scope:zhen_huan
						}
					}
				}
			}
			#They lose a bit of favor
			calyver_favor_minor_loss_effect = yes
		}
		add_opinion = {
			target = scope:langhua
			modifier = disapproving_opinion
		}

		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			craven = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
        ai_chance = {
            base = 50
        	ai_value_modifier = {
				ai_compassion = -0.4
				ai_boldness = 0.3
				ai_sociability = 0.2				
				ai_honor = 0.2
   			}
			opinion_modifier = {
				opinion_target = scope:zhen_huan
				multiplier = 0.2
			}
			compatibility_modifier = { #Trait compatibility
				compatibility_target = scope:zhen_huan
				multiplier = 0.15
			}

            modifier = { #Favor
				scope:langhua = { 
					has_character_modifier = unfavored_consort_modifier
				}
				add = 10
			}
			modifier = { #Favor
				scope:langhua = { 
					has_character_modifier = forgotten_consort_modifier
				}
				add = 20
			}

			modifier = { #The ancestors
				OR = {
					faith = { has_doctrine = tenet_ancestor_worship }
					culture = { has_cultural_tradition = tradition_mystical_ancestors }
				}
				add = 20
			}

			modifier = { #Traits
				has_trait = forgiving
				add = -25
			}
			modifier = { #Traits
				has_trait = compassionate
				add = -25
			}
			modifier = { #Traits
				has_trait = craven
				add = -25
			}
			modifier = { #Traits
				has_trait = shy
				add = -25
			}
        }
    }

	option = { # Try to make peace
        name = harem_politics.0036.c

		custom_tooltip = harem_politics.0036.c.tt

		duel = {
			skill = diplomacy
			value = high_skill_rating
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				send_interface_toast = {
					type = event_generic_good
					title = board_games.0001.tt.success
					left_icon = scope:zhen_huan
					right_icon = scope:langhua
					scope:zhen_huan = {
						add_opinion = {
							target = root
							modifier = pleased_opinion
							opinion = 10
						}
						add_opinion = {
							target = scope:langhua
							modifier = pleased_opinion
							opinion = 10
						}
						hidden_effect = {
							remove_opinion = {
								modifier = frustrated_opinion
								target = scope:langhua
							}
						}
					}
					scope:langhua = {
						add_opinion = {
							target = root
							modifier = pleased_opinion
							opinion = 10
						}
						add_opinion = {
							target = scope:zhen_huan
							modifier = pleased_opinion
							opinion = 10
						}
						hidden_effect = {
							remove_opinion = {
								modifier = frustrated_opinion
								target = scope:zhen_huan
							}
						}
					}
					stress_impact = {
						diligent = minor_stress_impact_loss
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				send_interface_toast = {
					type = event_generic_bad
					title = board_games.0001.tt.failure
					left_icon = scope:zhen_huan
					right_icon = scope:langhua
					scope:zhen_huan = {
						add_opinion = {
							target = root
							modifier = frustrated_opinion
							opinion = -10
						}
					}
					scope:langhua = {
						add_opinion = {
							target = root
							modifier = frustrated_opinion
							opinion = -10
						}
					}
				}
			}
		}

		ai_chance = {
            base = 50
        	ai_value_modifier = {
				ai_compassion = 0.25
				ai_boldness = 0.25
				ai_sociability = 0.4
				ai_honor = 0.2
   			}

			# Weight according to skills
			modifier = {
				add = {
					add = diplomacy
					multiply = 2
				}
				always = yes
			}
			modifier = { #Traits
				has_trait = diligent
				add = 25
			}
        }
    }

	option = { # Stay away from it
        name = harem_politics.0036.d
        
		scope:langhua = {
			add_opinion = {
				target = root
				modifier = frustrated_opinion
				opinion = -10
			}
		}
		
        stress_impact = {
			diligent = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
        }
		ai_chance = {
            base = 50
        	ai_value_modifier = {
				ai_compassion = -0.3
				ai_boldness = -0.3
				ai_sociability = -0.3
				ai_honor = -0.2
   			}

            modifier = { #Traits
				has_trait = diligent
				add = -25
			}
			modifier = { #Traits
				has_trait = forgiving
				add = -25
			}
			modifier = { #Traits
				has_trait = compassionate
				add = -25
			}
        }
    }
	after = {
		add_character_flag = {
			flag = had_zhenhuan_event_flag
			years = 3
		}
	}
}

#########################################################
##Muslim flavor - A matron presents you with concubines##
#########################################################
scripted_trigger valid_harem_politics_0037_province_trigger = {
	OR = {
		any_pool_character = {
			province = this
			recruit_concubines_viable_candidate_trigger = {
				OVERLORD = root
			}
			num_of_bad_genetic_traits = 0
		}
		NOT = {
			religion = religion:islam_religion
		}
	}
}

scripted_trigger valid_harem_matron_trigger = {
	is_valid_muslim_harem_relative_trigger = {
		LIEGE = root
	}
	NOR = { 
		is_consort_of = root 
		is_child_of = root

		has_relation_rival = root
		has_relation_nemesis = root

		has_trait = content
		has_trait = humble
		has_trait = compassionate
		has_trait = forgiving
	}
	is_healthy = yes
}

scripted_effect harem_politics_0038_make_concubine_effect = {
	base_make_concubine_harem_politics_events_effect = {
		CONSORT = $JARYA$
	}
	hidden_effect = {
		# The harem loses opinion of the matron
		every_courtier = {
			limit = {
				is_valid_harem_member_trigger = {
					LIEGE = root
				}
				NOR = {
					this = $JARYA$
					this = scope:matron
					has_opinion_modifier = {
						modifier = forced_me_concubine_marriage_opinion
						target = root
					}
					has_relation_friend = scope:matron
					has_relation_best_friend = scope:matron

					has_relation_lover = scope:matron
					has_relation_soulmate = scope:matron

					has_relation_rival = scope:matron
					has_relation_nemesis = scope:matron

					is_close_family_of = scope:matron

					scope:matron = {
						has_hook = prev
					}
				}
				hp_accepts_harems = yes
				opinion = {
					target = root
					value >= -15
				}
				harem_politics_evil_consort_trigger = yes
			}
			if = { # Your consorts hate competition more
				limit = {
					is_consort_of = root
				}
				add_opinion = {
					target = scope:matron
					modifier = upset_opinion
					opinion = -15
				}
				add_opinion = {
					target = $JARYA$
					modifier = upset_opinion
					opinion = -10
				}
			}
			else = {
				add_opinion = {
					target = scope:matron
					modifier = upset_opinion
					opinion = -10
				}
			}
		}
		scope:matron = {
			if = {
				limit = {
					can_add_hook = {
						target = $JARYA$
						type = favor_hook
					}
				}
				add_hook = {
					target = $JARYA$
					type = favor_hook
				}
			}
			add_opinion = {
				target = $JARYA$
				modifier = ally_at_court_opinion
				opinion = 15
			}
		}
		$JARYA$ = {
			add_opinion = {
				target = scope:matron
				modifier = ally_at_court_opinion
				opinion = 5
			}
			save_scope_as = potential_candidate
			if = {
				limit = {
					root = {
						any_consort = {
							is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
							has_variable = favor
							count >= 3
						}
					}
				}
				set_variable = {
					name = favor
					value = initial_favor_valuation
				}
				change_variable = {
					name = favor
					add = favor_high_value_gain
				}
			}
		}
	}
	save_scope_value_as = {
		name = gold_to_pay
		value = bride_compensation_payment_value
	}
	pay_short_term_gold = {
		target = scope:matron
		gold = bride_compensation_payment_value
	}
	scope:matron = {
		add_opinion = {
			target = root
			modifier = pleased_opinion
			opinion = 10
		}
		add_character_flag = {
			flag = flag_jarya_accepted
			years = 4
		}
	}
	stress_impact = {
		greedy = minor_stress_impact_gain
		chaste = minor_stress_impact_gain
		shy = minor_stress_impact_gain
		celibate = minor_stress_impact_gain
	}
}

harem_politics.0037 = {
	type = character_event
	title = harem_politics.0037.t
	desc = {
		desc = harem_politics.0037.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = {
						is_sibling_of = scope:matron
					}
				}
				desc = harem_politics.0037.parent.desc
			}
			desc = harem_politics.0037.sibling.desc
		}
		desc = harem_politics.0037.end.desc
	}
	theme = family
	override_background = {
		reference = study
	}
	
	left_portrait  = {
		character = scope:matron
		animation = personality_content
	}
	right_portrait = {
		character = root
		animation = personality_rational
	}
	
	trigger = {
		religion = religion:islam_religion
		hp_accepts_concubinage = yes
		allowed_more_concubines = yes
		gold >= minor_gold_value
		any_courtier = {
			valid_harem_matron_trigger = yes
		}
		OR = {
			any_realm_province = {
				valid_harem_politics_0037_province_trigger = yes
			}
			any_neighboring_and_across_water_top_liege_realm_owner = {
				any_realm_province = {
					valid_harem_politics_0037_province_trigger = yes
				}
			}
		}
		OR = { #Appropriate dominant sex
			AND = {
				is_male = no
				OR = {
					has_realm_law = female_only_law
					has_realm_law = female_preference_law
				}
			}
			AND = {
				is_male = yes
				OR = {
					has_realm_law = male_only_law
					has_realm_law = male_preference_law
				}
			}
			has_realm_law = equal_law
		}
		NOR = {
			has_character_flag = flag_jarya
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
			has_trait = pregnant
			has_character_modifier = mourner_modifier
	    }
		is_available_at_peace_adult = yes
		is_available_at_peace_adult = yes
		highest_held_title_tier >= tier_kingdom
	}

	weight_multiplier = {
		base = 1
		# Stress
		modifier = { #Stress
			add = 0.1
			stress_level >= 1
		}
		modifier = { #Stress
			add = 0.1
			stress_level >= 2
		}
		modifier = { #Stress
			add = 0.1
			stress_level = 3
		}

		modifier = {
			number_of_concubines < number_of_desired_concubines
			add = 0.15
		}
		modifier = {
			add = -0.5
			has_trait = chaste
		}
		modifier = {
			add = 0.2
			has_trait = lustful
		}
		modifier = {
			add = 0.2
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.3
			age >= 45
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.3
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		random_courtier = {
			limit = {
				valid_harem_matron_trigger = yes
			}
			weight = {
				base = 10
				modifier = {
					add = {
						value = age
						divide = 2
					}
				}
				modifier = {
					is_parent_of = root
					add = 10
				}
				modifier = {
					age > root.age
					add = 5
				}
				modifier = {
					has_trait = ambitious
					add = 15
				}
				modifier = {
					has_trait = greedy
					add = 15
				}
				modifier = {
					has_trait = lazy
					add = -15
				}
				modifier = { # They have already offered a concubine
					has_character_flag = flag_jarya_accepted
					add = 15
				}
			}
			save_scope_as = matron
		}
	}
	
	option = {
		name = harem_politics.0037.a
		stress_impact = {
			diligent = minor_stress_impact_gain
		}
		trigger_event = {
			id = harem_politics.0038
			days = { 2 4 }
		}

		ai_chance = {
            base = 10
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = 0.4
			}
			modifier = {
				has_trait = shy
				add = -10
			}
			modifier = {
				has_trait = chaste
				add = -10
			}
			modifier = {
				has_trait = lustful
				add = 15
			}
			modifier = {
				has_trait = lazy
				add = 10
			}
			modifier = {
				has_trait = diligent
				add = -35
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 15
			}
			modifier = {
				is_child_of = scope:matron
				add = 10
			}

			modifier = { #Stress
				add = 10
				stress_level >= 1
			}
			modifier = { #Stress
				add = 10
				stress_level >= 2
			}
			modifier = { #Stress
				add = 10
				stress_level = 3
			}
		}
	}

	option = {
		name = harem_politics.0037.b
		scope:matron = {
			add_opinion = {
				modifier = disappointed_opinion
				target = root
				opinion = -5
			}
		}
		ai_chance = {
            base = 10
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = -0.4
			}
			modifier = {
				has_trait = shy
				add = 10
			}
			modifier = {
				has_trait = chaste
				add = 10
			}
			modifier = {
				has_trait = content
				add = 10
			}
			modifier = {
				has_trait = lustful
				add = -15
			}
			modifier = {
				has_trait = diligent
				add = 35
			}
		}
	}

	after = {
		add_character_flag = {
			flag = flag_jarya
			years = 3
		}
	}
}

harem_politics.0038 = {
	type = character_event
	title = harem_politics.0038.t
	desc = harem_politics.0038.desc
	theme = family
	override_background = {
		reference = bedchamber
	}
	
	left_portrait  = {
		character = scope:matron
		animation = interested
	}
	right_portrait = {
		character = scope:jarya_1
		animation = personality_honorable
		outfit_tags = { spouse_outfit }
	}
	lower_left_portrait = {
		character = scope:jarya_2
		outfit_tags = { spouse_outfit }
	}
	lower_right_portrait = {
		character = scope:jarya_3
		outfit_tags = { spouse_outfit }
	}
	
	trigger = {
		exists = scope:matron
		OR = {
			any_realm_province = {
				valid_harem_politics_0037_province_trigger = yes
			}
			any_neighboring_and_across_water_top_liege_realm_owner = {
				any_realm_province = {
					valid_harem_politics_0037_province_trigger = yes
				}
			}
		}
	}
	
	immediate = {
		play_music_cue = mx_cue_banquet
		stress_impact = {
			base = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
		
		if = {
			limit = {
				any_realm_province = {
					valid_harem_politics_0037_province_trigger = yes
				}
			}
			every_realm_province = {
				limit = {
					valid_harem_politics_0037_province_trigger = yes
				}
				add_to_list = pool_provinces
			}
		}
		if = {
			limit = {
				any_neighboring_and_across_water_top_liege_realm_owner = {
					any_realm_province = {
						valid_harem_politics_0037_province_trigger = yes
					}
				}
			}
			every_neighboring_and_across_water_top_liege_realm_owner = {
				every_realm_province = {
					limit = {
						valid_harem_politics_0037_province_trigger = yes
					}
					add_to_list = pool_provinces
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = pool_provinces
					any_pool_character = {
						province = this
						recruit_concubines_viable_candidate_trigger = {
							OVERLORD = root
						}
						num_of_bad_genetic_traits = 0
					}
				}
			}
			every_in_list = {
				list = pool_provinces
				every_pool_character = {
					province = this
					limit = {
						recruit_concubines_viable_candidate_trigger = {
							OVERLORD = root
						}
						num_of_bad_genetic_traits = 0
					}
					add_to_list = pool_candidates
				}
			}
		}
		hidden_effect = {
			if = {
				limit = {
					any_in_list = {
						list = pool_candidates
						count < 3
					}
				}
				hp_select_concubine_location_effect = yes
				save_scope_as = liege
				while = {
					limit = {
						any_in_list = {
							list = pool_candidates
							count < 3
						}
					}
					calyver_create_candidate_effect = yes
				}
			}
			while = {
				count = 3
				random_in_list = {
					list = pool_candidates
					weight = {
						base = 10
						# Good genetics
						modifier = { #Trait considerations
							num_of_good_genetic_traits >= 1
							add = 15
						}
						modifier = {
							num_of_good_genetic_traits >= 2
							add = 20
						}
						modifier = {
							has_trait = beauty_good
							add = 10
						}
						modifier = {
							has_trait = beauty_good_2
							add = 5
						}
						modifier = {
							has_trait = beauty_good_3
							add = 10
						}
						modifier = {
							has_trait = chaste
							add = -5
						}
						# Skills and knowledge
						modifier = {
							add = diplomacy
						}
						modifier = {
							add = learning
						}
						modifier = {
							has_trait = poet
							add = 15
						}
						# The mother will prioritize someone from her homeland
						modifier = {
							scope:matron.culture != scope:harem_liege.culture
							culture = scope:matron.culture
							add = 15
						}
					}
					if = {
						limit = {
							NOT = {
								exists = scope:jarya_1
							}
						}
						save_scope_as = jarya_1
					}
					else_if = {
						limit = {
							NOT = {
								exists = scope:jarya_2
							}
						}
						save_scope_as = jarya_2
					}
					else = {
						save_scope_as = jarya_3
					}
					# A King+ wouldn't receive concubines with weight problems
					if = {
						limit = {
							has_character_modifier = malnourished_modifier
						}
						remove_character_modifier = malnourished_modifier
					}
					if = {
						limit = {
							current_weight <= underweight_value
						}
						change_current_weight = 60
					}
					if = {
						limit = {
							has_character_modifier = obese_modifier
						}
						remove_character_modifier = obese_modifier
					}
					if = {
						limit = {
							current_weight >= overweight_value
						}
						change_current_weight = -60
					}
					# They wouldn't present unconverted concubines
					if = {
						limit = {
							NOT = {
								has_character_flag = abducted_non_believer
							}
						}
						add_character_flag = {
							flag = abducted_non_believer
							years = 10
						}
					}
					set_character_faith = root.faith
					remove_from_list = pool_candidates
					add_to_list = jarya_list
				}
			}
		}
	}
	
	# Choose Jarya 1
	option = {
		name = harem_politics.0038.a
		trigger = {
			allowed_more_concubines = yes
			gold >= minor_gold_value
		}
		show_as_unavailable = { 
			NOT = { gold >= minor_gold_value }
			allowed_more_concubines = yes
		}
		harem_politics_0038_make_concubine_effect = {
			JARYA = scope:jarya_1
		}

		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_greed = -0.3
				ai_sociability = -0.3
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:jarya_1
				MAX_PERSONALITY = 25 # -25 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = scope:jarya_1
				multiplier = 0.5
			}

			modifier = {
				scope:jarya_1 = {
					has_trait = beauty_good
				}
				add = 5
			}
			modifier = {
				scope:jarya_1 = {
					has_trait = beauty_good_2
				}
				add = 5
			}
			modifier = {
				scope:jarya_1 = {
					has_trait = beauty_good_3
				}
				add = 10
			}
			modifier = {
				scope:jarya_1 = {
					num_of_good_genetic_traits >= 1
				}
				add = 5
			}
			modifier = {
				scope:jarya_1 = {
					num_of_good_genetic_traits > 1
				}
				add = 5
			}

			modifier = {
				has_trait = celibate
				add = -35
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = shy
				add = -25
			}
			modifier = {
				has_trait = chaste
				add = -35
			}

			modifier = {
				has_trait = lustful
				add = 15
			}

			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 15
			}
			modifier = {
				any_child = {
					is_alive = yes
					character_gender_can_inherit_from_trigger = { CHARACTER = root }
					count <= 3
				}
				add = 10
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

			modifier = {
				is_child_of = scope:matron
				add = 10
			}
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = 0.3
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:jarya_1 } }
				factor = 0.5
			}
		}
	}

	# Choose Jarya 2
	option = {
		name = harem_politics.0038.b
		trigger = {
			allowed_more_concubines = yes
			gold >= minor_gold_value
		}
		show_as_unavailable = { 
			NOT = { gold >= minor_gold_value }
			allowed_more_concubines = yes
		}
		harem_politics_0038_make_concubine_effect = {
			JARYA = scope:jarya_2
		}

		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_greed = -0.3
				ai_sociability = -0.3
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:jarya_2
				MAX_PERSONALITY = 25 # -25 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = scope:jarya_2
				multiplier = 0.5
			}

			modifier = {
				scope:jarya_2 = {
					has_trait = beauty_good
				}
				add = 5
			}
			modifier = {
				scope:jarya_2 = {
					has_trait = beauty_good_2
				}
				add = 5
			}
			modifier = {
				scope:jarya_2 = {
					has_trait = beauty_good_3
				}
				add = 10
			}
			modifier = {
				scope:jarya_2 = {
					num_of_good_genetic_traits >= 1
				}
				add = 5
			}
			modifier = {
				scope:jarya_2 = {
					num_of_good_genetic_traits > 1
				}
				add = 5
			}

			modifier = {
				has_trait = celibate
				add = -35
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = shy
				add = -25
			}
			modifier = {
				has_trait = chaste
				add = -35
			}

			modifier = {
				has_trait = lustful
				add = 15
			}

			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 15
			}
			modifier = {
				any_child = {
					is_alive = yes
					character_gender_can_inherit_from_trigger = { CHARACTER = root }
					count <= 3
				}
				add = 10
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

			modifier = {
				is_child_of = scope:matron
				add = 10
			}
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = 0.3
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:jarya_2 } }
				factor = 0.5
			}
		}
	}

	# Choose Jarya 3
	option = {
		name = harem_politics.0038.c
		trigger = {
			allowed_more_concubines = yes
			gold >= minor_gold_value
		}
		show_as_unavailable = { 
			NOT = { gold >= minor_gold_value }
			allowed_more_concubines = yes
		}
		harem_politics_0038_make_concubine_effect = {
			JARYA = scope:jarya_3
		}

		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_greed = -0.3
				ai_sociability = -0.3
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:jarya_3
				MAX_PERSONALITY = 25 # -25 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = scope:jarya_3
				multiplier = 0.5
			}

			modifier = {
				scope:jarya_3 = {
					has_trait = beauty_good
				}
				add = 5
			}
			modifier = {
				scope:jarya_3 = {
					has_trait = beauty_good_2
				}
				add = 5
			}
			modifier = {
				scope:jarya_3 = {
					has_trait = beauty_good_3
				}
				add = 10
			}
			modifier = {
				scope:jarya_3 = {
					num_of_good_genetic_traits >= 1
				}
				add = 5
			}
			modifier = {
				scope:jarya_3 = {
					num_of_good_genetic_traits > 1
				}
				add = 5
			}

			modifier = {
				has_trait = celibate
				add = -35
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = shy
				add = -25
			}
			modifier = {
				has_trait = chaste
				add = -35
			}

			modifier = {
				has_trait = lustful
				add = 15
			}

			modifier = {
				any_child = {
					is_alive = yes
					count = 0
				}
				add = 15
			}
			modifier = {
				any_child = {
					is_alive = yes
					character_gender_can_inherit_from_trigger = { CHARACTER = root }
					count <= 3
				}
				add = 10
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 20
			}

			modifier = {
				is_child_of = scope:matron
				add = 10
			}
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = 0.3
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:jarya_3 } }
				factor = 0.5
			}
		}
	}

	option = {
		name = harem_politics.0038.d
		scope:matron = {
			add_opinion = {
				modifier = disappointed_opinion
				target = root
				opinion = -5
			}
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_greed = 0.3
				ai_sociability = 0.3
			}
			modifier = {
				has_trait = temperate
				add = 10
			}
			modifier = {
				has_trait = celibate
				add = 35
			}
			modifier = {
				has_trait = greedy
				add = 25
			}
			modifier = {
				has_trait = shy
				add = 25
			}
			modifier = {
				has_trait = chaste
				add = 35
			}

			modifier = {
				has_trait = lustful
				add = -35
			}

			modifier = {
				is_child_of = scope:matron
				add = -10
			}
			opinion_modifier = {
				opinion_target = scope:matron
				multiplier = -0.5
			}
		}
	}

	after = {
		hidden_effect = {
			every_in_list = {
				list = jarya_list
				limit = {	
					NOT = { is_consort_of = root }
				}
				if = {
					limit = { NOT = { exists = var:last_visited_ruler } }
					set_variable = {
						name = last_visited_ruler
						value = scope:harem_liege
						days = 1825
					}
				}
				move_to_pool_at = root.location
			}
		}
	}
}

####################
##A reserved night##
####################
scripted_trigger is_valid_senior_consort_trigger = {
	is_available = yes
	is_healthy = yes
	court_owner ?= root

	harem_politics_punished_consort_trigger = no
	harem_politics_forgotten_consort_trigger = no
	is_demoted_consort_trigger = no

	OR = {
		is_spouse_of = root
		has_court_position = grand_consort_court_position
	}
	NOR = {
		has_trait = pregnant
		has_trait = celibate
		has_trait = chaste
		has_trait = devoted

		has_relation_rival = root
		has_relation_nemesis = root

		has_opinion_modifier = {
			target = root
			modifier = forced_me_concubine_marriage_opinion
		}
	}
	opinion = {
		target = root
		value >= -15
	}
}

scripted_trigger is_valid_new_consort_trigger = {
	is_available = yes
	is_healthy = yes
	court_owner ?= root

	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	is_demoted_consort_trigger = no

	trait_compatibility = {
		target = root
		value >= low_positive_trait_compatibility
	}

	has_character_flag = flag_new_consort
	is_attracted_to_gender_of = root
	root = {
		is_attracted_to_gender_of = prev
	}
	harem_politics_is_valid_authority_trigger = {
		AUTHORITY = $CONSORT$
		TARGET = this
		LIEGE = root
	}

	NOR = {
		has_trait = pregnant
		has_trait = celibate
		has_trait = devoted

		this = $CONSORT$

		has_relation_friend = $CONSORT$
		has_relation_lover = $CONSORT$

		has_relation_best_friend = $CONSORT$
		has_relation_soulmate = $CONSORT$

		has_relation_rival = root
		has_relation_nemesis = root
	}
	opinion = {
		target = root
		value >= -15
	}
}

harem_politics.0039 = {
	type = character_event
	title = harem_politics.0039.t
	desc = harem_politics.0039.desc
	theme = lover_relation
	override_background = {
		reference = bedchamber
	}
	
	left_portrait  = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = scope:consort_1
		animation = flirtation
	}

	lower_center_portrait = {
		character = scope:consort_2
	}
	
	trigger = {
		exists = scope:consort_1
		exists = scope:consort_2
		scope:harem_liege ?= {
			this = root
		}
	}
	
	immediate = {
		scope:consort_1 = {
			add_opinion = {
				target = root
				modifier = love_opinion
				opinion = 10
			}
		}
		add_opinion = {
			target = scope:consort_1
			modifier = love_opinion
			opinion = 5
		}
		stress_impact = {
			base = minor_stress_impact_loss
			gregarious = minor_stress_impact_loss
		}
	}
	
	# You respect your commitments
	option = {
		name = harem_politics.0039.a
		scope:consort_1 = {
			calyver_favor_minor_loss_effect = yes
			add_opinion = {
				modifier = disappointed_opinion
				target = root
				opinion = -10
			}
		}
		scope:consort_2 = {
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}
		had_sex_with_effect = {
			CHARACTER = scope:consort_2
			PREGNANCY_CHANCE = pregnancy_chance
		}

		stress_impact = {
			chaste = minor_stress_impact_gain
		}

		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_energy = 0.3
				ai_honor = 0.3
				ai_rationality = 0.4
			}
			opinion_modifier = {
				opinion_target = scope:consort_2
				multiplier = 0.5
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:consort_2
				MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			modifier = {
				scope:consort_2 = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:consort_2 = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:consort_2 = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = {
				has_trait = chaste
				add = -25
			}
		}
	}

	# Choose consort_1
	option = {
		name = harem_politics.0039.b
		scope:consort_1 = {
			calyver_favor_moderate_gain_effect = yes
			add_opinion = {
				target = root
				modifier = love_opinion
				opinion = 10
			}
			if = {
				limit = { 
					NOR = { 
						has_relation_lover = root
						has_relation_soulmate = root
					}
				}
				progress_towards_lover_effect = {
					CHARACTER = root
					REASON = lover_seduction_general
					OPINION = 0
				}
			}
		}
		if = {
			limit = {
				NOT = {
					has_trait = chaste
				}
			}
			had_sex_with_effect = {
				CHARACTER = scope:consort_1
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}
		scope:consort_2 = {
			calyver_favor_moderate_loss_effect = yes
			add_opinion = {
				modifier = disappointed_opinion
				target = root
				opinion = -10
			}
			hidden_effect = {
				if = {
					limit = {
						NOR = {
							has_trait = forgiving
							has_trait = compassionate
							has_trait = temperate
						}
					}
					add_opinion = {
						target = scope:consort_1
						modifier = hatred_spouse_opinion
						opinion = -15
					}
				}
				if = {
					limit = {
						has_trait = vengeful
					}
					if = {
						limit = {
							can_set_relation_rival_trigger = { CHARACTER = scope:secondary_actor }
						}
						progress_towards_rival_effect = {
							REASON = consort_rival_reason
							CHARACTER = scope:consort_1
							OPINION = 0
						}
					}
				}
			}
		}


		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_energy = -0.3
				ai_honor = -0.3
				ai_rationality = -0.4
			}
			opinion_modifier = {
				opinion_target = scope:consort_1
				multiplier = 0.5
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:consort_1
				MAX_PERSONALITY = 50 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 50 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			modifier = {
				scope:consort_1 = {
					has_character_modifier = favored_consort_modifier
				}
				add = 10
			}
			modifier = {
				scope:consort_1 = {
					has_character_modifier = favor_boost_modifier
				}
				add = 15
			}
			modifier = {
				scope:consort_1 = {
					has_character_modifier = beloved_consort_modifier
				}
				add = 20
			}
			modifier = {
				has_trait = chaste
				add = 25
			}
		}
	}

	after = {
		add_character_flag = {
			flag = flag_reserved_night
			years = 4
		}
	}
}

###################################################
##The Empress Dowager pushes you to favor an ally##
###################################################
scripted_trigger is_valid_relative_0040_trigger = {
	is_physically_able_ai = yes
	is_healthy = yes
	harem_politics_punished_consort_trigger = no

	trigger_if = {
		limit = {
			root.religion = religion:islam_religion
		}
		is_head_of_the_harem_trigger = {
			LIEGE = root
		}
	}
	trigger_else = {
		is_parent_of = root
	}

	NOR = {
		is_consort_of = root

		has_trait = pregnant

		has_relation_rival = root
		has_relation_nemesis = root

		has_relation_best_friend = root
		has_relation_friend = root

		has_trait = forgiving
		has_trait = compassionate
		has_trait = humble
		has_trait = content
		has_trait = trusting

		has_trait = shy
		has_trait = craven
	}
	trigger_if = {
		limit = {
			is_travelling = yes	
		}
		current_travel_plan = {
			travel_plan_owner = root
		}
	}
	trigger_else = {
		is_travelling = no
		root = {
			is_travelling = no
		}
	}
}

scripted_trigger is_valid_favorite_0040_trigger = {
	is_physically_able_ai = yes
	is_healthy = yes
	harem_politics_punished_consort_trigger = no
	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
	harem_politics_favored_consort_trigger = yes
	NOR = {
		has_relation_friend = $RELATIVE$
		has_relation_best_friend = $RELATIVE$

		has_relation_lover = $RELATIVE$
		has_relation_soulmate = $RELATIVE$

		$RELATIVE$ = {
			has_hook = prev
		}
	}
	trigger_if = {
		limit = {
			is_travelling = yes	
		}
		current_travel_plan = {
			travel_plan_owner = root
		}
	}
	trigger_else = {
		is_travelling = no
		root = {
			is_travelling = no
		}
	}
}

scripted_trigger is_valid_consort_0040_trigger = {
	is_physically_able_ai = yes
	is_healthy = yes
	harem_politics_punished_consort_trigger = no

	harem_politics_unfavored_consort_trigger = yes
	is_demoted_consort_trigger = no

	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }

	age <= 35
	is_concubine_of = root
	NOR = {
		this = $FAVORITE$
		has_trait = pregnant
		has_trait = intellect_bad

		has_relation_best_friend = $FAVORITE$
		has_relation_friend = $FAVORITE$

		has_relation_lover = $FAVORITE$
		has_relation_soulmate = $FAVORITE$

		has_relation_rival = $RELATIVE$
		has_relation_nemesis = $RELATIVE$

		has_relation_rival = root
		has_relation_nemesis = root

		has_relation_best_friend = root
		has_relation_friend = root

		has_relation_lover = root
		has_relation_soulmate = root
	}
	opinion = {
		target = root
		value >= -25
	}
	reverse_opinion = {
		target = $RELATIVE$
		value >= -25
	}
	trigger_if = {
		limit = {
			is_travelling = yes	
		}
		current_travel_plan = {
			travel_plan_owner = root
		}
	}
	trigger_else = {
		is_travelling = no
		root = {
			is_travelling = no
		}
	}
}

harem_politics.0040 = {
	type = character_event
	title = harem_politics.0040.t
	desc = harem_politics.0040.desc
	theme = family
	override_background = { reference = feast }
	
	left_portrait  = {
		character = root
		animation = shame
	}
	right_portrait = {
		character = scope:zhen_huan
		animation = disapproval
	}

	lower_left_portrait = {
		character = scope:consort_1
	}
	lower_center_portrait = {
		character = scope:favorite
	}
	lower_right_portrait = {
		character = scope:consort_2
	}
	
	trigger = {
		is_available_at_peace_adult = yes
		is_physically_able = yes
		is_healthy = yes
		any_courtier = {
			is_valid_relative_0040_trigger = yes
			save_temporary_scope_as = temp_zhen_huan
		}
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			count >= 4
		}
		any_consort = {
			is_valid_favorite_0040_trigger = {
				RELATIVE = scope:temp_zhen_huan
			}
			count = 1
			save_temporary_scope_as = temp_favorite
		}
		any_concubine = {
			is_valid_consort_0040_trigger = {
				RELATIVE = scope:temp_zhen_huan
				FAVORITE = scope:temp_favorite
			}
			count >= 2
		}
		NOR = {
			has_character_flag = flag_scolded_by_empress_dowager
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
			has_trait = pregnant
	    }
	}

	weight_multiplier = {
		base = 1
		modifier = { # Traits
			add = -0.3
			has_trait = chaste
		}
		modifier = {
			highest_held_title_tier >= tier_kingdom
			add = 0.15
		}
		modifier = { # No. of consorts
			add = 0.1
			any_consort = {
				is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
				count >= 7
			}
		}
		modifier = { # No. of consorts
			add = 0.1
			any_consort = {
				is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
				count >= 9
			}
		}
		# The GC
		# High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		# Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		stress_impact = {
			gregarious = minor_stress_impact_loss
		}

		if = {
			limit = {
				any_courtier = {
					is_valid_relative_0040_trigger = yes
					count > 1
				}
			}
			random_courtier = {
				limit = {
					is_valid_relative_0040_trigger = yes				
				}
				weight = {
					base = 1
					modifier = {
						sex_opposite_of = root
						add = 20
					}
					modifier = {
						add = head_of_the_harem_score_value
					}
				}
				save_scope_as = zhen_huan
			}
		}
		else = {
			random_courtier = {
				limit = {
					is_valid_relative_0040_trigger = yes				
				}
				save_scope_as = zhen_huan
			}
		}
		scope:zhen_huan = {
			add_opinion = {
				modifier = disapproval_opinion
				target = root
				opinion = -5
			}
		}

		random_consort = {
			limit = {
				is_valid_favorite_0040_trigger = {
					RELATIVE = scope:zhen_huan
				}
			}
			save_scope_as = favorite
		}
		every_consort = {
			limit = {
				is_valid_consort_0040_trigger = {
					RELATIVE = scope:zhen_huan
					FAVORITE = scope:favorite
				}
			}
			add_to_list = consort_0040_list
		}
		hidden_effect = {
			while = {
				count = 2
				random_in_list = {
					list = consort_0040_list
					weight = {
						base = 1
						opinion_modifier = { # Liege's opinion
							who = scope:zhen_huan
							opinion_target = this
							min = 0
							multiplier = 0.5
						}
						compatibility_modifier = { # Trait compatibility
							compatibility_target = scope:zhen_huan
							min = 0
							max = 40
							multiplier = 0.5
						}
						modifier = {
							scope:zhen_huan = {
								has_hook = prev
							}
							add = 50
						}
						modifier = {
							scope:zhen_huan = {
								has_strong_hook = prev
							}
							add = 100
						}
					}
					if = {
						limit = {
							NOT = {
								exists = scope:consort_1
							}
						}
						save_scope_as = consort_1
						scope:consort_1 = {
							remove_from_list = consort_0040_list
						}
					}
					else = {
						save_scope_as = consort_2
					}
					add_to_temporary_list = performing_consorts
				}
			}	
			every_in_list = {
				list = performing_consorts
				add_diplomacy_skill = 1
			}
		}
	}
	
	# You take consort_1
	option = {
		name = harem_politics.0040.a

		scope:consort_1 = {
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			hidden_effect = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = thankful_consort_opinion
					opinion = 15
				}
			}
		}
		had_sex_with_effect = {
			CHARACTER = scope:consort_1
			PREGNANCY_CHANCE = pregnancy_chance
		}

		scope:zhen_huan = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}


		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_boldness = -0.4
				ai_vengefulness = -0.2
				ai_honor = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:consort_1
				multiplier = 0.1
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:consort_1
				MAX_PERSONALITY = 10 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 10 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = scope:zhen_huan
				multiplier = 0.5
			}
		}
	}

	# You take consort_2
	option = {
		name = harem_politics.0040.b

		scope:consort_2 = {
			calyver_favor_minor_gain_effect = yes
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
			}
			hidden_effect = {
				add_opinion = {
					target = scope:zhen_huan
					modifier = thankful_consort_opinion
					opinion = 15
				}
			}
		}
		had_sex_with_effect = {
			CHARACTER = scope:consort_2
			PREGNANCY_CHANCE = pregnancy_chance
		}

		scope:zhen_huan = {
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 10
			}
		}


		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_boldness = -0.4
				ai_vengefulness = -0.2
				ai_honor = 0.15
			}
			opinion_modifier = {
				opinion_target = scope:consort_2
				multiplier = 0.1
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:consort_2
				MAX_PERSONALITY = 10 # -50 at low trait combatibility, +150 at high trait combatibility.
				MAX_PHYSICAL = 10 # Will be -25 by default (due to Rakish) but can vary from between -150 and +150 due to other Attraction modifiers.
			}
			opinion_modifier = {
				opinion_target = scope:zhen_huan
				multiplier = 0.5
			}
		}
	}

	# Don't intervene in my harem
	option = {
		name = harem_politics.0040.c
		scope:favorite = {
			calyver_favor_minor_gain_effect = yes
			if = {
				limit = {
					NOR = {
						has_relation_rival = root
						has_relation_nemesis = root

						has_opinion_modifier = {
							target = root
							modifier = forced_me_concubine_marriage_opinion
						}
					}
					opinion = {
						target = root
						value >= -15
					}
				}
				if = {
					limit = { can_set_relation_potential_lover_trigger = { CHARACTER = root } }
					set_relation_potential_lover = root
					add_opinion = {
						target = root
						modifier = love_opinion
						opinion = 10
					}
				}
				else = {
					add_opinion = {
						target = root
						modifier = thankful_consort_opinion
					}
				}
			}
		}
		scope:consort_1 = {
			calyver_favor_minor_loss_effect = yes
		}
		scope:consort_2 = {
			calyver_favor_minor_loss_effect = yes
		}

		scope:zhen_huan = {
			add_opinion = {
				target = root
				modifier = frustrated_opinion
				opinion = -10
			}
			hidden_effect = {
				add_opinion = {
					target = scope:favorite
					modifier = frustrated_opinion
					opinion = -10
				}
			}
		}

		stress_impact = {
			craven = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_boldness = 0.4
				ai_vengefulness = 0.2
				ai_honor = -0.25
			}
			opinion_modifier = {
				opinion_target = scope:zhen_huan
				multiplier = -0.5
			}
			modifier = {
				has_trait = craven
				add = -35
			}
		}
	}

	after = {
		add_character_flag = {
			flag = flag_scolded_by_empress_dowager
			years = 4
		}
	}
}

#################
##Chaotic harem##
#################
scripted_trigger killer_consort_0041_trigger = {
	is_valid_harem_member_trigger = {
		LIEGE = root
	}
	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
	is_imprisoned = no
}

scripted_trigger favorite_evil_consort_trigger = {
	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
	harem_politics_punished_consort_trigger = no
	harem_politics_favored_consort_trigger = yes
	is_demoted_consort_trigger = no
	is_imprisoned = no
}

harem_politics.0041 = {
	type = character_event
	title = harem_politics.0041.t
	desc = harem_politics.0041.desc
	theme = corruption
	override_background = {
		reference = throne_room
	}
	
	left_portrait  = {
		character = root
		animation = disapproval
	}
	right_portrait = {
		character = scope:harem_head
		animation = shame
	}
	
	trigger = {
		is_available_at_peace_adult = yes
		is_physically_able = yes
		any_courtier = {
			is_head_of_the_harem_trigger = {
				LIEGE = root
			}
		}
		any_former_spouse = { # Two dead high-ranking consorts
			is_alive = no
			killer ?= {
				killer_consort_0041_trigger = yes
			}
			count >= 2
		}
		any_child = { # Two dead children
			is_alive = no
			has_any_bastard_trait_trigger = no
			NOR = {
				has_trait = bastard_founder
			}
			killer ?= {
				killer_consort_0041_trigger = yes
				is_consort_of = root
			}
			count >= 2
		}
		any_courtier = {
			is_valid_harem_member_trigger = {
				LIEGE = root
			}
			OR = {
				any_relation = {
					type = rival
					is_valid_harem_member_trigger = {
						LIEGE = root
					}
				}
				any_relation = {
					type = nemesis
					is_valid_harem_member_trigger = {
						LIEGE = root
					}
				}
			}
			count >= 4
		}
		any_consort = {
			favorite_evil_consort_trigger = yes
			count >= 1
		}
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			count >= 4
		}

		NOR = {
			has_character_modifier = poisonous_court_modifier
			AND = {
				employs_court_position = grand_consort_court_position
				any_court_position_holder = {
					type = grand_consort_court_position
					aptitude:grand_consort_court_position >= 4
					has_character_flag = gc_promoting_harmony
				}
			}
	    }
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.15
			any_consort = {
				has_character_flag = flag_yanwan
			}
		}
		modifier = {
			add = 0.15
			any_consort = {
				has_character_flag = flag_mei
			}
		}
		modifier = {
			add = 0.15
			any_consort = {
				has_character_flag = flag_hailan
			}
		}
		modifier = {
			add = 0.1
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			any_former_spouse = { # Two dead high-ranking consorts
				is_alive = no
				killer ?= {
					killer_consort_0041_trigger = yes
				}
				count >= 3
			}
			add = 0.1
		}
		modifier = {
			any_child = {
				is_alive = no
				has_any_bastard_trait_trigger = no
				NOR = {
					has_trait = bastard_founder
				}
				killer ?= {
					killer_consort_0041_trigger = yes
					is_consort_of = root
				}
				count >= 3
			}
			add = 0.1
		}
		modifier = {
			any_courtier = {
				is_valid_harem_member_trigger = {
					LIEGE = root
				}
				OR = {
					any_relation = {
						type = rival
						is_valid_harem_member_trigger = {
							LIEGE = root
						}
					}
					any_relation = {
						type = nemesis
						is_valid_harem_member_trigger = {
							LIEGE = root
						}
					}
				}
				count >= 6
			}
			add = 0.1
		}
		modifier = {
			any_consort = {
				favorite_evil_consort_trigger = yes
				count >= 2
			}
			add = 0.1
		}
		# The GC
		# High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		# Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.1
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		stress_impact = {
			base = minor_stress_impact_gain
		}

		ordered_courtier = {
			limit = {
				is_head_of_the_harem_trigger = {
					LIEGE = root
				}
			}
			order_by = {
				value = head_of_the_harem_score_value
			}
			max = 1
			save_scope_as = harem_head
		}
	}
	
	# Blame the head of the harem
	option = {
		name = harem_politics.0041.a

		add_prestige = minor_prestige_loss
		scope:harem_head = {
			if = {
				limit = {
					is_consort_of = root
				}
				calyver_favor_moderate_loss_effect = yes
			}
			add_prestige = minor_prestige_loss
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -25
			}
		}
		every_courtier_or_guest = {
			limit = {
				NOT = {
					this = scope:harem_head
				}
			}
			custom = court_6000_all_courtiers_and_guests
			if = {
				limit = {
					NOR = {
						has_relation_friend = scope:harem_head
						has_relation_best_friend = scope:harem_head
	
						has_relation_lover = scope:harem_head
						has_relation_soulmate = scope:harem_head
	
						is_close_family_of = scope:harem_head
					}
				}
				add_opinion = {
					target = scope:harem_head
					modifier = disappointed_opinion
					opinion = -15
				}
			}
			if = {
				limit = {
					NOR = {
						has_relation_friend = root
						has_relation_best_friend = root
	
						has_relation_lover = root
						has_relation_soulmate = root
					}
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
		}

		stress_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_honor = -0.25
				ai_compassion = -0.4
			}
			opinion_modifier = {
				opinion_target = scope:harem_head
				multiplier = -0.5
			}
			modifier = {
				has_trait = arrogant
				add = 25
			}
			modifier = {
				has_trait = forgiving
				add = -25
			}
			modifier = {
				has_trait = compassionate
				add = -25
			}
			modifier = {
				scope:harem_head = {
					is_parent_of = root
				}
				add = -15
			}
			modifier = {
				scope:harem_head = {
					OR = {
						is_grandparent_of = root
						is_uncle_or_aunt_of = root
					}
				}
				add = -10
			}
		}
	}

	# Accept the blame
	option = {
		name = harem_politics.0041.b

		add_prestige = minor_prestige_gain
		every_courtier_or_guest = {
			custom = court_6000_all_courtiers_and_guests
			if = {
				limit = {
					NOR = {
						has_relation_friend = scope:harem_head
						has_relation_best_friend = scope:harem_head
	
						has_relation_lover = scope:harem_head
						has_relation_soulmate = scope:harem_head
					}
				}
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -25
				}
			}
		}


		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_honor = 0.25
				ai_compassion = 0.4
			}
			opinion_modifier = {
				opinion_target = scope:harem_head
				multiplier = 0.5
			}
			modifier = {
				has_trait = arrogant
				add = -25
			}
			modifier = {
				has_trait = forgiving
				add = 25
			}
			modifier = {
				has_trait = compassionate
				add = 25
			}
			modifier = {
				scope:harem_head = {
					is_parent_of = root
				}
				add = 15
			}
			modifier = {
				scope:harem_head = {
					OR = {
						is_grandparent_of = root
						is_uncle_or_aunt_of = root
						root.primary_spouse ?= scope:harem_head
					}
				}
				add = 10
			}
		}
	}

	after = {
		add_character_modifier = {
			modifier = poisonous_court_modifier
			years = 10
		}
		every_courtier_or_guest = {
			custom = court_6000_all_courtiers_and_guests
			add_character_modifier = {
				modifier = poisonous_court_modifier
				years = 10
			}
		}
	}
}

##################
##Meeting Hailan##
##################
scripted_trigger ruyi_0042_trigger = {
	is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
	harem_politics_punished_consort_trigger = no
	harem_politics_unfavored_consort_trigger = no
	is_demoted_consort_trigger = no
	is_imprisoned = no
}
harem_politics.1042 = {
	hidden = yes
	
	trigger = {
		is_available_healthy_adult = yes
		is_available_at_peace_adult = yes
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			count >= 3
		}
		any_consort = {
			ruyi_0042_trigger = yes
			save_temporary_scope_as = valid_target_consort
		}
		allowed_more_concubines = yes
		harem_politics_valid_event_county_trigger = yes
		NOR = {
			has_character_flag = met_flag_hailan
			has_trait = chaste
			has_trait = celibate
			has_trait = devoted
			has_trait = eunuch
			has_trait = pregnant
			has_trait = temperate
	    }
		# Fornication needs to be considered at least shunned
		trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = root.faith TRAIT = fornicator GENDER_CHARACTER = scope:valid_target_consort }

	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_trait = drunkard
			add = 0.25
		}
		modifier = {
			has_trait = lustful
			add = 0.15
		}
		modifier = {
			has_trait = fornicator
			add = 0.1
		}
		modifier = {
			has_trait = adulterer
			add = 0.1
		}

		modifier = { # Less likely if you don't have guards around you all day
			highest_held_title_tier < tier_kingdom
			add = 0.15
		}
		modifier = { # More likely if you have many servants
			has_ep1_dlc_trigger = yes
			has_royal_court = yes
			amenity_level = {
				type = court_servants
				value >= 3
			}
			add = 0.15
		}

		modifier = { # No. of consorts
			add = 0.1
			number_of_concubines < number_of_desired_concubines
		}
		# The GC
		# High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		# Choose the reference location
		hp_select_concubine_location_effect = yes
		#Create Hailan
		hp_character_creation_effect = {
			CHARACTER = hailan
		}
		trigger_event = harem_politics.0042
	}
}

harem_politics.0042 = {
	type = character_event
	title = harem_politics.0042.t
	desc = harem_politics.0042.desc
	theme = corruption
	override_background = {
		reference = throne_room
	}
	
	left_portrait  = {
		character = scope:ruyi
		animation = beg
	}
	right_portrait = {
		character = scope:hailan
		animation = shame
	}
	
	trigger = {
		exists = scope:hailan
	}
	
	immediate = {
		show_as_tooltip = {
			had_sex_with_effect = {
				CHARACTER = scope:hailan
				PREGNANCY_CHANCE = pregnancy_chance
			}
		}
		scope:hailan = {
			add_opinion = {
				target = root
				modifier = upset_opinion
				opinion = -15
			}
			add_trait = fornicator
		}
		
		random_courtier = {
			limit = {
				is_valid_harem_member_trigger = {
					LIEGE = root
				}
				trigger_if = {
					limit = {
						is_consort_of = root
					}
					ruyi_0042_trigger = yes
				}
			}
			weight = {
				base = 1
				modifier = {
					has_trait = just
					add = 15
				}
				modifier = {
					is_spouse_of = root
					add = 10
				}
				modifier = {
					harem_politics_evil_consort_trigger = no
					add = 15
				}
				modifier = {
					harem_politics_favored_consort_trigger = yes
					add = 10
				}
				modifier = {
					add = {
						value = ai_compassion
						min = 0
					}
				}
				opinion_modifier = {
					opinion_target = scope:hailan
					multiplier = 0.20
					min = 0
				}
			}
			save_scope_as = ruyi
		}
	}
	
	# Take Hailan as a consort
	option = {
		name = harem_politics.0042.a
		trigger = {
			allowed_more_concubines = yes
		}

		add_prestige = minor_prestige_gain
		add_piety = minor_piety_loss

		base_make_concubine_harem_politics_events_effect = {
			CONSORT = scope:hailan
		}
		scope:hailan = {
			remove_trait = fornicator
			add_character_flag = flag_hailan
		}
		
		scope:ruyi = {
			calyver_favor_micro_gain_effect = yes
			# Ruyi and Hailan become friends
			if = {
				limit = {
					can_set_relation_friend_trigger = { CHARACTER = scope:hailan }
				}
				set_relation_friend = { 
					target = scope:hailan
					reason = consort_friendship_reason
				}
			}
			add_opinion = {
				target = root
				modifier = thankful_consort_opinion
				opinion = 10
			}
			hidden_effect = { # Hailan becomes loyal to Ruyi
				add_hook = {
					type = loyalty_hook
					target = scope:hailan
				}
			}
		}
		hidden_effect = {
			every_consort = { # Other consorts will think Ruyi shoved a consort to gain favor
				limit = {
					is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
					NOR = {
						this = scope:hailan
						this = scope:ruyi
						has_relation_friend = scope:ruyi
						has_relation_best_friend = scope:ruyi
						has_relation_lover = scope:ruyi
						has_relation_soulmate = scope:ruyi
					}
					harem_politics_evil_consort_trigger = yes
				}
				add_opinion = {
					target = scope:ruyi
					modifier = upset_opinion
					opinion = -15
				}
				add_opinion = {
					target = scope:hailan
					modifier = upset_opinion
					opinion = -15
				}
			}
		}

		if = { # How could you sleep with a lowborn?
			limit = {
				scope:hailan = {
					is_lowborn = yes
				}
			}
			stress_impact = {
				arrogant = minor_stress_impact_gain
			}
		}
		stress_impact = { # Taking them as a concubine is admitting to your sins too
			zealous = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_vengefulness = -0.15
				ai_honor = 0.15
				ai_compassion = 0.4
				ai_zeal = -0.4
   			}
			opinion_modifier = {
				opinion_target = scope:ruyi
				multiplier = 0.5
			}
			opinion_modifier = {
				opinion_target = scope:hailan
				multiplier = 0.15
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:hailan
				MAX_PERSONALITY = 15
				MAX_PHYSICAL = 20
			}
			modifier = {
				has_trait = arrogant
				scope:hailan = {
					is_lowborn = yes
				}
				add = -25
			}
			modifier = {
				has_trait = zealous
				add = -25
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 10
			}
			modifier = {
				NOT = { root = { is_attracted_to_gender_of = scope:hailan } }
				factor = 0.75
			}
		}
	}

	# Forget it
	option = {
		name = harem_politics.0042.b

		scope:ruyi = {
			calyver_favor_micro_loss_effect = yes
			add_opinion = {
				target = root
				modifier = upset_opinion
				opinion = -15
			}
		}
		hidden_effect = {
			scope:hailan = {
				death = {
					death_reason = death_vanished
				}
			}
		}
		stress_impact = {
			forgiving = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
            base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.15
				ai_honor = -0.15
				ai_compassion = -0.4
				ai_zeal = 0.4
   			}
			opinion_modifier = {
				opinion_target = scope:ruyi
				multiplier = -0.5
			}
			opinion_modifier = {
				opinion_target = scope:hailan
				multiplier = -0.15
			}
			simple_attraction_modifier = {
				WHO = root
				TARGET = scope:hailan
				MAX_PERSONALITY = -15
				MAX_PHYSICAL = -20
			}
			modifier = {
				has_trait = compassionate
				add = -25
			}
			modifier = {
				has_trait = forgiving
				add = -25
			}
		}
	}

	after = {
		add_character_flag = met_flag_hailan
	}
}

#########################
##Imprisoning a consort##
#########################
harem_politics.1000 = {
	type = character_event
	title = char_interaction.0231.title
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { is_in_prison_type = house_arrest }
				}
				desc = char_interaction.0231.desc_house_arrest
			}
			desc = char_interaction.0231.desc_prison
		}
	}
		
	right_portrait = {
		character = scope:recipient
		animation = sadness
	}
	theme = prison
	
	immediate = {
	}

	option = {
		name = char_interaction.0231.a
	}
}

############################################
##Qi is jealous of Xin - error suppression##
############################################
harem_politics.1013 = {
	type = character_event
	hidden = yes
	
	trigger = {
		any_consort = {
			is_courtier_of = root
			count >= 4
		}
		any_consort = {
			harem_politics_qi_trigger = yes
			save_temporary_scope_as = reference_qi_pin
		}
		any_consort = {
			harem_politics_xin_trigger = { QI = scope:reference_qi_pin }
		}
		NOR = {
			has_character_flag = flag_qi_pin_xin_guiren_event
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
			has_trait = pregnant
	    }
		is_physically_able_adult = yes
		is_at_war = no
		is_landed_or_landless_administrative = yes
	}
	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.2
			highest_held_title_tier >= tier_kingdom
		}
		modifier = {
			add = -0.5
			has_trait = chaste
		}
		modifier = {
			add = 0.2
			has_trait = lustful
		}
		modifier = {
			add = 0.2
			any_child = {
				count <= 1
			}
		}
		modifier = {
			add = -0.4
			age >= 45
		}
		#The GC
		#High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.2
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		#Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		every_consort = {
			limit = {
				harem_politics_qi_trigger = yes
			}
			add_to_list = qi_pin_list
		}
		random_in_list = { #Imperial Concubine Qi
			list = qi_pin_list
			weight = {
				base = 30
				modifier = {
					NOT = {
						has_character_flag = flag_new_consort
					}
					add = 10
				}
				modifier = {
					has_character_modifier = favored_consort_modifier
					add = 15
				}
				# modifier = { #More if Xin is favored
				# 	scope:xin_guiren = {
				# 		OR = {	
				# 			has_character_modifier = favored_consort_modifier
				# 			has_character_modifier = beloved_consort_modifier
				# 		}
				# 	}
				# 	OR = {	
				# 		has_character_modifier = favored_consort_modifier
				# 		has_character_modifier = beloved_consort_modifier
				# 	}
				# 	add = 15
				# }
				# modifier = { #Beloved consorts don't need to do these things for favor
				# 	has_character_modifier = beloved_consort_modifier
				# 	scope:xin_guiren = {
				# 		NOR = {	
				# 			has_character_modifier = favored_consort_modifier
				# 			has_character_modifier = beloved_consort_modifier
				# 		}
				# 	}
				# 	add = -15
				# }
				modifier = {
					is_concubine = yes
					add = 15
				}
				modifier = {
					any_close_family_member = {
						OR = {
							is_powerful_vassal_of = root
							is_councillor_of = root
						}
					}
					add = 30
				}
				modifier = {
					is_lowborn = no
					add = 10
				}
				modifier = {
					has_trait = arrogant
					add = 20
				}
				modifier = {
					has_trait = ambitious
					add = 20
				}
				modifier = {
					has_trait = greedy
					add = 20
				}
				modifier = {
					has_trait = deceitful
					add = 10
				}
				modifier = {
					has_trait = lustful
					add = 10
				}
				modifier = {
					has_trait = brave
					add = 10
				}
				modifier = {
					has_trait = generous
					add = -15
				}
				modifier = {
					has_character_modifier = scheming_consort_modifier
					add = 10
				}
			}
			save_scope_as = qi_pin
		}

		every_consort = {
			limit = {
				harem_politics_xin_trigger = { QI = scope:qi_pin }
			}
			add_to_list = xin_guiren_list
		}
		
		random_in_list = { #Noble Lady Xin
			list = xin_guiren_list
			weight = {
				base = 10
				modifier = {
					has_character_modifier = unfavored_consort_modifier
					add = 10
				}
				modifier = {
					has_character_modifier = forgotten_consort_modifier
					add = 20
				}
				modifier = {
					is_lowborn = yes
					add = 30
				}
				modifier = {
					has_trait = shy
					add = 10
				}
				modifier = {
					has_trait = craven
					add = 10
				}
				modifier = {
					has_court_position = grand_consort_court_position
					add = -15
				}
				modifier = {
					is_concubine = yes
					add = 15
				}

				modifier = {
					has_relation_potential_rival = scope:qi_pin
					add = 5
				}
				modifier = {
					has_relation_rival = scope:qi_pin
					add = 10
				}
				modifier = {
					has_relation_nemesis = scope:qi_pin
					add = 20
				}
				opinion_modifier = {
					who = scope:qi_pin
					opinion_target = this
					multiplier = -0.20
				}
			}
			save_scope_as = xin_guiren
		}
		if = {
			limit = {
				exists = scope:xin_guiren
				exists = scope:qi_pin
			}
			trigger_event = harem_politics.0013
		}
	}
}

########################################
##A reserved night - error suppression##
########################################
harem_politics.1039 = {
	type = character_event
	hidden = yes
	
	trigger = {
		is_available_at_peace_adult = yes
		any_consort = {
			is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
			count >= 3
		}
		any_consort = {
			is_valid_senior_consort_trigger = yes
			save_temporary_scope_as = temporary_consort
		}
		any_consort = {
			is_valid_new_consort_trigger = {
				CONSORT = scope:temporary_consort
			}
		}
		NOR = {
			has_character_flag = flag_reserved_night
			has_trait = eunuch
			has_trait = celibate
			has_trait = devoted
			has_trait = pregnant
	    }
	}

	weight_multiplier = {
		base = 1
		modifier = { # Traits
			add = -0.3
			has_trait = chaste
		}
		modifier = { # Traits
			add = 0.15
			has_trait = lustful
		}
		modifier = { # Traits
			has_trait = gregarious
			add = 0.2
		}
		modifier = { # No. of consorts
			add = 0.1
			any_consort = {
				is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
				count >= 5
			}
		}
		modifier = { # No. of consorts
			add = 0.1
			any_consort = {
				is_valid_for_favor_system_trigger = { HAREM_LIEGE = root }
				count >= 7
			}
		}
		# The GC
		# High aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 3
				has_character_flag = gc_promoting_harmony
			}
			add = -0.1
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position >= 4
				has_character_flag = gc_promoting_harmony
			}
			add = -0.15
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 5
				has_character_flag = gc_promoting_harmony
			}
			add = -0.25
		}
		# Low aptitude
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position <= 2
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
		modifier = {
			employs_court_position = grand_consort_court_position
			any_court_position_holder = {
				type = grand_consort_court_position
				aptitude:grand_consort_court_position = 1
				has_character_flag = gc_promoting_harmony
			}
			add = 0.25
		}
	}
	
	immediate = {
		save_scope_as = harem_liege
		
		random_consort = {
			limit = {
				is_valid_senior_consort_trigger = yes				
			}
			weight = {
				base = 1
				modifier = {
					exists = root.primary_spouse
					this = root.primary_spouse
					add = 15
				}
				modifier = {
					has_court_position = grand_consort_court_position
					add = 5
				}
				modifier = {
					NOT = { has_character_flag = flag_new_consort }
					add = 5
				}
				modifier = {
					harem_politics_evil_consort_trigger = yes
					add = 15
				}
			}
			save_scope_as = consort_2
		}
		if = {
			limit = {
				exists = scope:consort_2
			}
			random_consort = {
				limit = {
					is_valid_new_consort_trigger = {
						CONSORT = scope:consort_2
					}
				}
				weight = {
					base = 1
					opinion_modifier = { # Liege's opinion
						who = root
						opinion_target = this
						min = 0
						multiplier = 0.2
					}
					compatibility_modifier = { # Trait compatibility
						compatibility_target = root
						min = 0
						max = 40
						multiplier = 2
					}
					modifier = {
						is_concubine = yes
						add = 20
					}
					modifier = {
						has_relation_potential_rival = scope:consort_2
						add = 5
					}
					modifier = {
						has_relation_rival = scope:consort_2
						add = 10
					}
					modifier = {
						has_relation_nemesis = scope:consort_2
						add = 20
					}
				}
				save_scope_as = consort_1
			}
			if = {
				limit = {
					exists = scope:consort_1
				}
				trigger_event = harem_politics.0039
			}
		}
	}
}